From 00fd009ce01333443c2ff855e24058430a871a9e Mon Sep 17 00:00:00 2001 From: liguoyang Date: Mon, 10 Jun 2024 21:46:49 +0800 Subject: [PATCH] =?UTF-8?q?feat=20=E6=A0=B9=E6=8D=AE=E5=B7=A5=E5=8F=B7?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=B5=B7=E5=AE=81=E6=B6=88=E8=B4=B9=E8=AE=B0?= =?UTF-8?q?=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Order/Controllers/BalancesController.cs | 17 ++++++++- .../BalanceHainingDownloadResponse.cs | 37 +++++++++++++++++++ .../Order/Services/IBalanceService.cs | 6 ++- .../Services/Implements/BalanceService.cs | 36 ++++++++++++++++-- 4 files changed, 89 insertions(+), 7 deletions(-) create mode 100644 Src/Dlhis.Canteen/Order/Response/BalanceHainingDownloadResponse.cs diff --git a/Src/Dlhis.Canteen/Order/Controllers/BalancesController.cs b/Src/Dlhis.Canteen/Order/Controllers/BalancesController.cs index a4ea63cc..83dcacab 100644 --- a/Src/Dlhis.Canteen/Order/Controllers/BalancesController.cs +++ b/Src/Dlhis.Canteen/Order/Controllers/BalancesController.cs @@ -1,4 +1,5 @@ -using Dlhis.Canteen.Order.Request; +using System.ComponentModel.DataAnnotations; +using Dlhis.Canteen.Order.Request; using Dlhis.Canteen.Order.Response; using Dlhis.Canteen.Order.Services; using Kurisu.AspNetCore.DataAccess.Dto; @@ -148,6 +149,18 @@ public class BalancesController : ControllerBase [HttpPost("haining/import")] public async Task Import(BalanceHainingImportRequest request) { - await _balanceService.Import(request); + await _balanceService.HainingImportAsync(request); + } + + /// + /// 根据工号海宁餐补数据获取 + /// + /// 工号 + /// + [IgnoreTenant] + [HttpGet("haining/list")] + public async Task> HainingDownloadAsync([Required(ErrorMessage = "工号不能为空")] string userCode) + { + return await _balanceService.HainingDownloadAsync(userCode); } } \ No newline at end of file diff --git a/Src/Dlhis.Canteen/Order/Response/BalanceHainingDownloadResponse.cs b/Src/Dlhis.Canteen/Order/Response/BalanceHainingDownloadResponse.cs new file mode 100644 index 00000000..36cf51af --- /dev/null +++ b/Src/Dlhis.Canteen/Order/Response/BalanceHainingDownloadResponse.cs @@ -0,0 +1,37 @@ +using Dlhis.Entity.Canteen.Enums; +using Kurisu.AspNetCore.Utils.Converters; +using Newtonsoft.Json; + +namespace Dlhis.Canteen.Order.Response +{ + public class BalanceHainingDownloadResponse + { + //工号、消费厂区、人员档案厂区、人事范围(若有)、部门(若有)、成本日期,消费时间,备注,金额,type,source,营业点,设备号,流水号, + + public string No { get; set; } + + public string Factory { get; set; } + public string OriginFactory { get; set; } + public string Werks { get; set; } + public string DepartmentNo { get; set; } + public string DepartmentName { get; set; } + + [JsonConverter(typeof(ToDateJsonConverter))] + public DateTime CostDate { get; set; } + + [JsonConverter(typeof(ToDateJsonConverter), "yyyy-MM-dd HH:mm:ss.fff")] + public DateTime CostDateTime { get; set; } + + public string Remark { get; set; } + + public decimal Amount { get; set; } + + public BalanceRecordTypeEnumType Type { get; set; } + + public BalanceRecordSourceEnumType Source { get; set; } + + public string BusinessPlaceCode { get; set; } + + public string DeviceUniqueNo { get; set; } + } +} \ No newline at end of file diff --git a/Src/Dlhis.Canteen/Order/Services/IBalanceService.cs b/Src/Dlhis.Canteen/Order/Services/IBalanceService.cs index 6454181b..33fb3a07 100644 --- a/Src/Dlhis.Canteen/Order/Services/IBalanceService.cs +++ b/Src/Dlhis.Canteen/Order/Services/IBalanceService.cs @@ -31,5 +31,7 @@ public interface IBalanceService : IScopeDependency Task> GetConsumeDeviceAsync(GetConsumeDeviceRequest request); - Task Import(BalanceHainingImportRequest request); -} + Task HainingImportAsync(BalanceHainingImportRequest request); + + Task> HainingDownloadAsync(string userCode); +} \ No newline at end of file diff --git a/Src/Dlhis.Canteen/Order/Services/Implements/BalanceService.cs b/Src/Dlhis.Canteen/Order/Services/Implements/BalanceService.cs index d0c720ac..96046a19 100644 --- a/Src/Dlhis.Canteen/Order/Services/Implements/BalanceService.cs +++ b/Src/Dlhis.Canteen/Order/Services/Implements/BalanceService.cs @@ -494,7 +494,7 @@ public class BalanceService : IBalanceService return page; } - public async Task Import(BalanceHainingImportRequest request) + public async Task HainingImportAsync(BalanceHainingImportRequest request) { var gainfo = await _dbContext.Queryable().Where(x => x.Code == request.UserCode).SingleAsync(); gainfo.ThrowIfNull($"工号{request.UserCode}不存在"); @@ -510,7 +510,7 @@ public class BalanceService : IBalanceService ShiftCode = c.Code }) .SingleAsync(); - + if (request.Type == BalanceRecordTypeEnumType.Out) { businessPlace.ThrowIfNull($"营业点{request.BusinessPlaceCode}不存在"); @@ -529,12 +529,12 @@ public class BalanceService : IBalanceService UserNo = gainfo.No, No = request.No, UserCode = gainfo.Code, - TenantId = request.Factory, Status = BalanceRecordStatusEnumType.Valid, Source = request.Source, Remark = request.Remark, CostId = gainfo.CostId, SubsidiesFromMonth = request.CostDate.ToString("yyyyMM"), + TenantId = request.Factory, OriginTenantId = gainfo.Factory, Werks = gainfo.Werks, Name = gainfo.Name, @@ -561,6 +561,36 @@ public class BalanceService : IBalanceService .ExecuteCommandThrowVersionAsync("写入失败,正在消费中"); } + /// + public async Task> HainingDownloadAsync(string userCode) + { + return await _dbContext.Queryable() + .LeftJoin((record, ga) => record.UserNo == ga.No) + .LeftJoin((record, ga, department) => ga.DepartmentNo == department.No) + .LeftJoin((record, ga, department, bPlace) => record.BusinessPlaceCode == bPlace.Code) + .Where(record => record.Status == BalanceRecordStatusEnumType.Valid) + .Where((record, ga) => ga.Code == userCode) + .OrderBy(record => record.CreateTime, OrderByType.Desc) + .Select((record, ga, department, bPlace) => new BalanceHainingDownloadResponse + { + No = record.No, + Factory = record.TenantId, + OriginFactory = record.OriginTenantId, + Werks = record.Werks, + DepartmentNo = record.DepartmentNo, + DepartmentName = department.Name, + CostDate = record.CostDate, + CostDateTime = record.CostDateTime, + Remark = record.Remark, + Amount = SqlFunc.Abs(record.Amount), + Type = record.Type, + Source = record.Source, + BusinessPlaceCode = bPlace.CustomCode, + DeviceUniqueNo = record.DeviceUniqueNo + }) + .ToListAsync(); + } + /// /// 获取离线设备