From 098d7c7e9d81c3d4b728b4be9545b6845a85331b Mon Sep 17 00:00:00 2001 From: liguoyang Date: Tue, 19 Mar 2024 14:26:24 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/DishesMenusController.cs | 4 +- .../Request/DishesCategorySaveRequest.cs | 7 + .../Response/BalanceRecordSourceEnumDto.cs | 12 +- .../BusinessShiftMealRelationshipResponse.cs | 39 ++- .../DishesMenusBookingSettingResponse.cs | 19 ++ .../Dishes/Response/DishesResponse.cs | 2 + .../Response/GetDishesMenusBookingResponse.cs | 15 -- .../Dishes/Services/IDishesService.cs | 2 +- .../Services/Implements/DishesService.cs | 17 +- .../Controllers/GainfosController.cs | 35 +-- .../Response/GainfoDetailResponse.cs | 8 - .../Services/Implements/GainfoService.cs | 242 +++--------------- .../Canteen/Entities/DishesCategoryEntity.cs | 10 +- 13 files changed, 110 insertions(+), 302 deletions(-) create mode 100644 Src/Dlhis.Basic/Dishes/Response/DishesMenusBookingSettingResponse.cs delete mode 100644 Src/Dlhis.Basic/Dishes/Response/GetDishesMenusBookingResponse.cs diff --git a/Src/Dlhis.Basic/Dishes/Controller/DishesMenusController.cs b/Src/Dlhis.Basic/Dishes/Controller/DishesMenusController.cs index 31c24e25..71137d10 100644 --- a/Src/Dlhis.Basic/Dishes/Controller/DishesMenusController.cs +++ b/Src/Dlhis.Basic/Dishes/Controller/DishesMenusController.cs @@ -51,7 +51,7 @@ public class DishesMenusController : ControllerBase } /// - /// 菜单明细 + /// 菜单信息明细 /// /// /// @@ -103,7 +103,7 @@ public class DishesMenusController : ControllerBase /// /// [HttpGet("setting")] - public async Task GetDishesMenusBookingSetting([FromQuery] GetDishesMenusBookingRequest request) + public async Task GetDishesMenusBookingSetting([FromQuery] GetDishesMenusBookingRequest request) { return await _dishesService.GetDishesMenusBookingSetting(request); } diff --git a/Src/Dlhis.Basic/Dishes/Request/DishesCategorySaveRequest.cs b/Src/Dlhis.Basic/Dishes/Request/DishesCategorySaveRequest.cs index 80582418..604dfe68 100644 --- a/Src/Dlhis.Basic/Dishes/Request/DishesCategorySaveRequest.cs +++ b/Src/Dlhis.Basic/Dishes/Request/DishesCategorySaveRequest.cs @@ -6,6 +6,13 @@ public class DishesCategorySaveRequest { public long? Id { get; set; } + + /// + /// 营业点 + /// + [Required] + public Guid BusinessPlaceCode { get; set; } + /// /// PCode /// diff --git a/Src/Dlhis.Basic/Dishes/Response/BalanceRecordSourceEnumDto.cs b/Src/Dlhis.Basic/Dishes/Response/BalanceRecordSourceEnumDto.cs index 9740a562..8a1570f6 100644 --- a/Src/Dlhis.Basic/Dishes/Response/BalanceRecordSourceEnumDto.cs +++ b/Src/Dlhis.Basic/Dishes/Response/BalanceRecordSourceEnumDto.cs @@ -1,11 +1,11 @@ using Dlhis.Entity.Canteen.Enums; using Kurisu.AspNetCore.Utils.Extensions; -namespace Dlhis.Basic.Dishes.Response +namespace Dlhis.Basic.Dishes.Response; + +public class BalanceRecordSourceEnumDto { - public class BalanceRecordSourceEnumDto - { - public BalanceRecordSourceEnumType Type { get; set; } - public string TypeCN => Type.GetDescription(); - } + public BalanceRecordSourceEnumType Type { get; set; } + + public string TypeDesc => Type.GetDescription(); } diff --git a/Src/Dlhis.Basic/Dishes/Response/BusinessShiftMealRelationshipResponse.cs b/Src/Dlhis.Basic/Dishes/Response/BusinessShiftMealRelationshipResponse.cs index 1c40fc37..0b49fd9f 100644 --- a/Src/Dlhis.Basic/Dishes/Response/BusinessShiftMealRelationshipResponse.cs +++ b/Src/Dlhis.Basic/Dishes/Response/BusinessShiftMealRelationshipResponse.cs @@ -1,29 +1,28 @@ using Dlhis.Entity.Canteen.Enums; using Kurisu.AspNetCore.Utils.Extensions; -namespace Dlhis.Basic.Dishes.Response +namespace Dlhis.Basic.Dishes.Response; + +public class BusinessShiftMealRelationshipResponse { - public class BusinessShiftMealRelationshipResponse - { - /// - /// 餐别Code - /// - public Guid ShiftCode { get; set; } + /// + /// 餐别Code + /// + public Guid ShiftCode { get; set; } - /// - /// 餐别手工号 - /// - public string ShiftCustomCode { get; set; } + /// + /// 餐别手工号 + /// + public string ShiftCustomCode { get; set; } - /// - /// 餐次 - /// - public ShiftEnumType ShiftType { get; set; } + /// + /// 餐次 + /// + public ShiftEnumType ShiftType { get; set; } - /// - /// 餐次CN - /// - public string ShiftTypeCN => ShiftType.GetDescription(); + /// + /// 餐次CN + /// + public string ShiftTypeDesc => ShiftType.GetDescription(); - } } diff --git a/Src/Dlhis.Basic/Dishes/Response/DishesMenusBookingSettingResponse.cs b/Src/Dlhis.Basic/Dishes/Response/DishesMenusBookingSettingResponse.cs new file mode 100644 index 00000000..8e492bc5 --- /dev/null +++ b/Src/Dlhis.Basic/Dishes/Response/DishesMenusBookingSettingResponse.cs @@ -0,0 +1,19 @@ +namespace Dlhis.Basic.Dishes.Response; + +public class DishesMenusBookingSettingResponse +{ + /// + /// 服务端时间 + /// + public DateTime ServerTime { get; set; } + + /// + /// 餐别-餐次信息 + /// + public List ShiftInfos { get; set; } + + /// + /// 支付方式 + /// + public List PayTypes { get; set; } +} diff --git a/Src/Dlhis.Basic/Dishes/Response/DishesResponse.cs b/Src/Dlhis.Basic/Dishes/Response/DishesResponse.cs index c2b58d8e..8e0f30aa 100644 --- a/Src/Dlhis.Basic/Dishes/Response/DishesResponse.cs +++ b/Src/Dlhis.Basic/Dishes/Response/DishesResponse.cs @@ -5,6 +5,8 @@ namespace Dlhis.Basic.Dishes.Response; public class DishesResponse { + public long Id { get; set; } + /// /// 分类 /// diff --git a/Src/Dlhis.Basic/Dishes/Response/GetDishesMenusBookingResponse.cs b/Src/Dlhis.Basic/Dishes/Response/GetDishesMenusBookingResponse.cs deleted file mode 100644 index 5473a443..00000000 --- a/Src/Dlhis.Basic/Dishes/Response/GetDishesMenusBookingResponse.cs +++ /dev/null @@ -1,15 +0,0 @@ -using Dlhis.Entity.Canteen.Enums; -using SqlSugar.DbConvert; -using SqlSugar; - -namespace Dlhis.Basic.Dishes.Response -{ - public class GetDishesMenusBookingResponse - { - public List BusinessShiftMealRelationships { get; set; } - - public DateTime ServiceTime { get; set; } - - public List PayTypes { get; set; } - } -} diff --git a/Src/Dlhis.Basic/Dishes/Services/IDishesService.cs b/Src/Dlhis.Basic/Dishes/Services/IDishesService.cs index 6d6830a9..f9c0fbfd 100644 --- a/Src/Dlhis.Basic/Dishes/Services/IDishesService.cs +++ b/Src/Dlhis.Basic/Dishes/Services/IDishesService.cs @@ -12,6 +12,6 @@ public interface IDishesService : IScopeDependency Task GetDishesDetailByIdAsync(long id); - Task GetDishesMenusBookingSetting(GetDishesMenusBookingRequest request); + Task GetDishesMenusBookingSetting(GetDishesMenusBookingRequest request); } diff --git a/Src/Dlhis.Basic/Dishes/Services/Implements/DishesService.cs b/Src/Dlhis.Basic/Dishes/Services/Implements/DishesService.cs index 79fc41d6..dbd90b56 100644 --- a/Src/Dlhis.Basic/Dishes/Services/Implements/DishesService.cs +++ b/Src/Dlhis.Basic/Dishes/Services/Implements/DishesService.cs @@ -8,20 +8,16 @@ using Kurisu.Core.DataAccess.Dto; using Kurisu.SqlSugar.Extensions; using Kurisu.SqlSugar.Services; using Mapster; -using System.Collections.Generic; -using System.Globalization; namespace Dlhis.Basic.Dishes.Services.Implements; public class DishesService : IDishesService { private readonly IDbContext _dbContext; - private readonly IConfiguration _configuration; - public DishesService(IDbContext dbContext, IConfiguration configuration) + public DishesService(IDbContext dbContext) { _dbContext = dbContext; - _configuration = configuration; } public async Task> GetDishesPageAsync(DishesPageRequest request) @@ -35,6 +31,7 @@ public class DishesService : IDishesService .OrderBy(x => x.CreateTime, SqlSugar.OrderByType.Desc) .Select((x, category) => new DishesResponse { + Id = x.Id, CurrnetUnits = x.Units.ToString(), CategoryName = category.Name, @@ -61,7 +58,7 @@ public class DishesService : IDishesService } } - public async Task GetDishesMenusBookingSetting(GetDishesMenusBookingRequest request) + public async Task GetDishesMenusBookingSetting(GetDishesMenusBookingRequest request) { // 读取最晚订餐的时间 var strDatetime = await _dbContext.Queryable() @@ -72,9 +69,9 @@ public class DishesService : IDishesService DateTime dateTime; DateTime.TryParseExact(strDatetime, "HH:mm:ss", null, System.Globalization.DateTimeStyles.None, out dateTime); - var res = new GetDishesMenusBookingResponse + var res = new DishesMenusBookingSettingResponse { - ServiceTime = dateTime, + ServerTime = dateTime, }; var shift = await _dbContext.Queryable() @@ -94,7 +91,7 @@ public class DishesService : IDishesService .Where(x => x.ShiftCode == shift.ShiftCode) .Select() .ToListAsync(); - res.BusinessShiftMealRelationships = businessShiftMealRelationships; + res.ShiftInfos = businessShiftMealRelationships; if (shift.TenantId == request.Factory) { @@ -108,7 +105,7 @@ public class DishesService : IDishesService } res.PayTypes = payTypes; return res; - } + } public async Task GetDishesDetailByIdAsync(long id) { diff --git a/Src/Dlhis.Basic/Organization/Controllers/GainfosController.cs b/Src/Dlhis.Basic/Organization/Controllers/GainfosController.cs index a3a881e5..b2b9d996 100644 --- a/Src/Dlhis.Basic/Organization/Controllers/GainfosController.cs +++ b/Src/Dlhis.Basic/Organization/Controllers/GainfosController.cs @@ -2,6 +2,7 @@ using Dlhis.Basic.Organization.Request; using Dlhis.Basic.Organization.Response; using Dlhis.Basic.Organization.Services; +using Kurisu.AspNetCore.DataAccess.SqlSugar.Aop; using Kurisu.Core.DataAccess.Dto; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; @@ -45,39 +46,6 @@ public class GainfosController : ControllerBase return await _gainfoService.GetPageAsync(request); } - /// - /// 档案表修改 - /// - /// - /// - [HttpPut("update")] - public async Task UpdateAsync(GainfoSaveRequest request) - { - await _gainfoService.UpdateAsync(request); - } - - /// - /// 离职 - /// - /// - /// - [HttpPost("dimission")] - public async Task DimissionAsync(GainfoDimissionRequest request) - { - await _gainfoService.DimissionAsync(request); - } - - /// - /// 入职 - /// - /// - /// - [HttpPost("onboarding")] - public async Task OnboardingAsync(GainfoDimissionRequest request) - { - await _gainfoService.OnboardingAsync(request); - } - /// /// 当前人员信息,余额 /// @@ -93,6 +61,7 @@ public class GainfosController : ControllerBase /// /// [HttpPost("face")] + [Transactional] public async Task UploadFaceAsync(GainfoUploadFaceRequest request) { await _gainfoService.UploadFaceAsync(request); diff --git a/Src/Dlhis.Basic/Organization/Response/GainfoDetailResponse.cs b/Src/Dlhis.Basic/Organization/Response/GainfoDetailResponse.cs index 6a3488fa..af1460b3 100644 --- a/Src/Dlhis.Basic/Organization/Response/GainfoDetailResponse.cs +++ b/Src/Dlhis.Basic/Organization/Response/GainfoDetailResponse.cs @@ -1,7 +1,5 @@ using Dlhis.Entity.Basic.Enums; using Kurisu.AspNetCore.Utils.Extensions; -using SqlSugar; -using System.ComponentModel.DataAnnotations; namespace Dlhis.Basic.Organization.Response; @@ -122,17 +120,11 @@ public class GainfoDetailResponse /// public string NationName { get; set; } - /// /// 人脸base64 /// public string Face { get; set; } - /// - /// 在职状态 - /// - public string Status { get; set; } - /// /// 厂区 /// diff --git a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs index 137700de..9a4ff4c2 100644 --- a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs +++ b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs @@ -13,7 +13,6 @@ using Kurisu.SqlSugar.Services; using Mapster; using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Mvc; -using System.IdentityModel.Tokens.Jwt; using System.Linq.Expressions; namespace Dlhis.Basic.Organization.Services.Implements; @@ -28,7 +27,6 @@ public class GainfoService : IGainfoService private readonly IServiceProvider _serviceProvider; private readonly IConfiguration _configuration; private readonly ILogger _logger; - private readonly IDepartmentService _departmentService; public GainfoService(IGainfoStore gainfoStore, IDbContext dbContext, @@ -48,7 +46,6 @@ public class GainfoService : IGainfoService _serviceProvider = serviceProvider; _configuration = configuration; _logger = logger; - _departmentService = departmentService; } /// @@ -427,13 +424,6 @@ public class GainfoService : IGainfoService OnboardingDate = ga.CreateTime, }) .FirstAsync(); - info.Status = request.Status.GetDescription(); - var trees = await _departmentService.GetTreeAsync(); - var res = trees.First(x => x.No == info.Factory); - if (res != null) - { - info.FactoryName = res.Name; - } if (info != null) { @@ -446,201 +436,6 @@ public class GainfoService : IGainfoService return info; } - public async Task>> GetWeekNumberAsync(WeekNumberRequest request, string token) - { - var werks = GetClaimValueFromToken(token, "tenant"); - - //获取近7天并转化为"yyyy-MM-dd"集合 - DateTime currentDate = DateTime.Now; - List times = new List(); - for (int i = 0; i < 7; i++) - { - DateTime date = currentDate.AddDays(-i); - string dateString = date.ToString("yyyy-MM-dd"); - times.Add(dateString); - } - - var dic = new Dictionary>(); - - foreach (var time in times) - { - var infos = await _gainfoStore.Queryable(GainfoStatusEnumType.Working) - .LeftJoin((ga, de) => ga.DepartmentNo == de.No) - .LeftJoin((ga, de, type) => ga.Native == type.Code && type.Type == "native") - .LeftJoin((ga, de, type, posi) => ga.Position == posi.Name) - .LeftJoin((ga, de, type, posi, type2) => ga.CountryNo == type2.Code && type2.Type == "country") - .LeftJoin((ga, de, type, posi, type2, type3) => ga.Nation == type3.Code && type3.Type == "nation") - .Where(ga => ga.CreateTime.ToString("yyyy-MM-dd") == time && ga.Werks == werks) - .Select((ga, de, type, posi, type2, type3) => new GainfoDetailResponse - { - No = ga.No, - SapNo = ga.SapNo, - Name = ga.Name, - Code = ga.Code, - DepartmentName = de.Name, - IdClass = ga.IdClass, - IdNo = ga.IdNo, - Gender = ga.Gender, - NativeName = type.Display, - Address = ga.Address, - Birthday = ga.Birthday, - Phone = ga.Phone, - Position = ga.Position, - Grade = posi.Grade, - Degree = ga.Degree, - Werks = ga.Werks, - CostId = ga.CostId, - Marital = ga.Marital, - CountryName = type2.Display, - NationName = type3.Display, - }).ToPageListAsync(request); - - dic[time] = infos; - } - return dic; - } - - public async Task>> GetDimissionWeekNumberAsync(WeekNumberRequest request, string token) - { - var werks = GetClaimValueFromToken(token, "tenant"); - - //获取近7天并转化为"yyyy-MM-dd"集合 - DateTime currentDate = DateTime.Now; - List times = new List(); - for (int i = 0; i < 7; i++) - { - DateTime date = currentDate.AddDays(-i); - string dateString = date.ToString("yyyy-MM-dd"); - times.Add(dateString); - } - - var dic = new Dictionary>(); - foreach (var time in times) - { - var infos = await _gainfoStore.Queryable(GainfoStatusEnumType.Leave) - .LeftJoin((ga, de) => ga.DepartmentNo == de.No) - .LeftJoin((ga, de, type) => ga.Native == type.Code && type.Type == "native") - .LeftJoin((ga, de, type, posi) => ga.Position == posi.Name) - .LeftJoin((ga, de, type, posi, type2) => ga.CountryNo == type2.Code && type2.Type == "country") - .LeftJoin((ga, de, type, posi, type2, type3) => ga.Nation == type3.Code && type3.Type == "nation") - .Where(ga => ga.CreateTime.ToString("yyyy-MM-dd") == time && ga.Werks == werks) - .Select((ga, de, type, posi, type2, type3) => new GainfoDetailResponse - { - No = ga.No, - SapNo = ga.SapNo, - Name = ga.Name, - Code = ga.Code, - DepartmentName = de.Name, - IdClass = ga.IdClass, - IdNo = ga.IdNo, - Gender = ga.Gender, - NativeName = type.Display, - Address = ga.Address, - Birthday = ga.Birthday, - Phone = ga.Phone, - Position = ga.Position, - Grade = posi.Grade, - Degree = ga.Degree, - Werks = ga.Werks, - CostId = ga.CostId, - Marital = ga.Marital, - CountryName = type2.Display, - NationName = type3.Display, - }).ToPageListAsync(request); - dic[time] = infos; - } - return dic; - } - - public async Task GetGainfoNumbersAsync(string token) - { - var werks = GetClaimValueFromToken(token, "tenant"); - - //在职人数 - var onlineNumber = await _gainfoStore.Queryable(GainfoStatusEnumType.Working) - .Where(ga => ga.Werks == werks) - .CountAsync(); - - //离职人数 - var offlineNumber = await _gainfoStore.Queryable(GainfoStatusEnumType.Leave) - .Where(ga => ga.Werks == werks) - .CountAsync(); - - //考勤总人数 - var attendanceNumber = onlineNumber + offlineNumber; - - var res = new GainfoGainfoNumbersResponse - { - OnlineNumber = onlineNumber, - OfflineNumber = offlineNumber, - AttendanceNumber = attendanceNumber - }; - return res; - } - - //-------------------------------------------help methods ------------------------------------------------ - - /// - /// 递归获取部门No - /// - /// - /// - private async Task> GetRecursionDepartmentNosAsync(List departmentNos) - { - if (departmentNos.IsEmpty()) - { - return new List(); - } - - var departments = await _dbContext.Queryable().ToListAsync(); - var currentNos = departments.Where(x => departmentNos.Contains(x.No)).ToList(); - - foreach (var item in currentNos) - { - RecursionGetNext(item.No, departments, departmentNos); - } - - return departmentNos.Distinct().ToList(); - - void RecursionGetNext(string currentCode, List departments, List result) - { - var next = departments.Where(x => x.PNo == currentCode).ToList(); - - foreach (var item in next) - { - result.Add(item.No); - RecursionGetNext(item.No, departments, result); - } - } - } - - /// - /// 解析token - /// - /// - /// - /// - /// - private string GetClaimValueFromToken(string token, string claimType) - { - try - { - var handler = new JwtSecurityTokenHandler(); - var jsonToken = handler.ReadToken(token) as JwtSecurityToken; - - if (jsonToken == null) - throw new Exception("Invalid JWT Token"); - - var claimValue = jsonToken.Claims.FirstOrDefault(c => c.Type == claimType)?.Value; - - return claimValue; - } - catch (Exception ex) - { - return null; - } - } - public async Task MigrationAsync(MigrationRequest request) { //档案数据 @@ -677,4 +472,41 @@ public class GainfoService : IGainfoService } } } + + //-------------------------------------------help methods ------------------------------------------------ + + /// + /// 递归获取部门No + /// + /// + /// + private async Task> GetRecursionDepartmentNosAsync(List departmentNos) + { + if (departmentNos.IsEmpty()) + { + return new List(); + } + + var departments = await _dbContext.Queryable().ToListAsync(); + var currentNos = departments.Where(x => departmentNos.Contains(x.No)).ToList(); + + foreach (var item in currentNos) + { + RecursionGetNext(item.No, departments, departmentNos); + } + + return departmentNos.Distinct().ToList(); + + void RecursionGetNext(string currentCode, List departments, List result) + { + var next = departments.Where(x => x.PNo == currentCode).ToList(); + + foreach (var item in next) + { + result.Add(item.No); + RecursionGetNext(item.No, departments, result); + } + } + } + } diff --git a/Src/Dlhis.Entity/Canteen/Entities/DishesCategoryEntity.cs b/Src/Dlhis.Entity/Canteen/Entities/DishesCategoryEntity.cs index 0f40049f..7ee20c16 100644 --- a/Src/Dlhis.Entity/Canteen/Entities/DishesCategoryEntity.cs +++ b/Src/Dlhis.Entity/Canteen/Entities/DishesCategoryEntity.cs @@ -7,6 +7,12 @@ namespace Dlhis.Entity.Canteen.Entities; [SugarTable(TableName = "DishesCategory", TableDescription = "菜品分类")] public class DishesCategoryEntity : SugarBaseEntity, ITenantId { + /// + /// 营业点 + /// + [SugarColumn(ColumnDescription = "营业点", IsNullable = false)] + public Guid BusinessPlaceCode { get; set; } + /// /// PCode /// @@ -21,13 +27,13 @@ public class DishesCategoryEntity : SugarBaseEntity, ITenantId /// /// 分类名称 /// - [SugarColumn(IsNullable = false, ColumnDescription = "名称")] + [SugarColumn(ColumnDescription = "名称", IsNullable = false)] public string Name { get; set; } /// /// 序号 /// - [SugarColumn(IsNullable = false, ColumnDescription = "序号", DefaultValue = "100")] + [SugarColumn(ColumnDescription = "序号", IsNullable = false, DefaultValue = "100")] public int Sequence { get; set; } = 100;