From 25194a86a39fc2b305d943b5319a1ba592bc91d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B5=87=E6=96=87=E9=BE=99?= Date: Wed, 30 Oct 2024 11:03:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E5=A4=8D=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Fee/Interface/IFeeCustTemplateService.cs | 11 ++++- .../Fee/Method/FeeCustTemplateService.cs | 45 ++++++++++++++++--- .../Controllers/FeeCustTemplateController.cs | 15 ++++++- 3 files changed, 63 insertions(+), 8 deletions(-) diff --git a/ds-wms-service/DS.WMS.Core/Fee/Interface/IFeeCustTemplateService.cs b/ds-wms-service/DS.WMS.Core/Fee/Interface/IFeeCustTemplateService.cs index 8a0929a8..6567aab8 100644 --- a/ds-wms-service/DS.WMS.Core/Fee/Interface/IFeeCustTemplateService.cs +++ b/ds-wms-service/DS.WMS.Core/Fee/Interface/IFeeCustTemplateService.cs @@ -59,11 +59,18 @@ namespace DS.WMS.Core.Fee.Interface /// Task BulkEditDetailsAsync(List details); + /// + /// 复制模板 + /// + /// + /// + Task CopyAsync(params long[] ids); + /// /// 根据ID批量删除 /// - /// + /// /// - Task DeleteAsync(IdModel model); + Task DeleteAsync(params long[] ids); } } diff --git a/ds-wms-service/DS.WMS.Core/Fee/Method/FeeCustTemplateService.cs b/ds-wms-service/DS.WMS.Core/Fee/Method/FeeCustTemplateService.cs index 410b217a..ae306228 100644 --- a/ds-wms-service/DS.WMS.Core/Fee/Method/FeeCustTemplateService.cs +++ b/ds-wms-service/DS.WMS.Core/Fee/Method/FeeCustTemplateService.cs @@ -1,6 +1,5 @@ using DS.Module.Core; using DS.Module.Core.Condition; -using DS.Module.Core.Data; using DS.Module.Core.Extensions; using DS.WMS.Core.Code.Entity; using DS.WMS.Core.Fee.Dtos; @@ -593,7 +592,7 @@ namespace DS.WMS.Core.Fee.Method /// /// /// - public async Task BulkEditAsync(List list) + public async Task BulkEditAsync(List list) { int rows = await TenantDb.Updateable(list).UpdateColumns(x => new { @@ -674,14 +673,50 @@ namespace DS.WMS.Core.Fee.Method return rows > 0 ? DataResult.Success : DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed)); } + /// + /// 复制模板 + /// + /// + /// + public async Task CopyAsync(params long[] ids) + { + long userId = long.Parse(User.UserId); + DateTime dt = DateTime.Now; + + var list = await TenantDb.Queryable().Where(x => ids.Contains(x.Id)) + .Includes(x => x.Details).ToListAsync(); + + foreach (var item in list) + { + item.Id = 0; + item.CreateTime = dt; + item.CreateBy = userId; + item.UpdateBy = null; + item.UpdateTime = null; + item.Name += "-Copy"; + item.DeptOrgId ??= User.OrgId; + + foreach (var detail in item.Details) + { + detail.Id = 0; + detail.TemplateId = 0; + detail.CreateBy = userId; + detail.CreateTime = dt; + } + } + + var boolValue = await TenantDb.InsertNav(list).Include(x => x.Details).ExecuteCommandAsync(); + return boolValue ? DataResult.Success : DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed)); + } + /// /// 根据ID批量删除 /// - /// + /// /// - public async Task DeleteAsync(IdModel model) + public async Task DeleteAsync(params long[] ids) { - bool flag = await TenantDb.DeleteNav(x => model.Ids.Contains(x.Id)) + bool flag = await TenantDb.DeleteNav(x => ids.Contains(x.Id)) .Include(x => x.Details).ExecuteCommandAsync(); return flag ? DataResult.Success : DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed)); } diff --git a/ds-wms-service/DS.WMS.FeeApi/Controllers/FeeCustTemplateController.cs b/ds-wms-service/DS.WMS.FeeApi/Controllers/FeeCustTemplateController.cs index fd07742f..bfe84c96 100644 --- a/ds-wms-service/DS.WMS.FeeApi/Controllers/FeeCustTemplateController.cs +++ b/ds-wms-service/DS.WMS.FeeApi/Controllers/FeeCustTemplateController.cs @@ -166,6 +166,19 @@ namespace DS.WMS.FeeApi.Controllers return await _invokeService.BulkEditDetailsAsync(details); } + /// + /// 复制模板 + /// + /// + /// + public async Task CopyAsync([FromBody] IdModel model) + { + if (!ModelState.IsValid) + return DataResult.Failed(ModelState.GetErrorMessage(), MultiLanguageConst.IllegalRequest); + + return await _invokeService.CopyAsync(model.Ids); + } + /// /// 详情 /// @@ -188,7 +201,7 @@ namespace DS.WMS.FeeApi.Controllers if (!ModelState.IsValid) return DataResult.Failed(ModelState.GetErrorMessage(), MultiLanguageConst.IllegalRequest); - return await _invokeService.DeleteAsync(model); + return await _invokeService.DeleteAsync(model.Ids); } ///