diff --git a/ds-wms-service/DS.WMS.Core/Application/Dtos/ApplicationDto.cs b/ds-wms-service/DS.WMS.Core/Application/Dtos/ApplicationDto.cs index d447b9ec..d7ae71c6 100644 --- a/ds-wms-service/DS.WMS.Core/Application/Dtos/ApplicationDto.cs +++ b/ds-wms-service/DS.WMS.Core/Application/Dtos/ApplicationDto.cs @@ -1,5 +1,4 @@ -using System.Runtime.Serialization; -using DS.Module.Core.Extensions; +using DS.Module.Core.Extensions; namespace DS.WMS.Core.Application.Dtos { @@ -98,7 +97,6 @@ namespace DS.WMS.Core.Application.Dtos /// /// 所属分部 /// - [IgnoreDataMember] public long? SaleDeptId { get; set; } /// diff --git a/ds-wms-service/DS.WMS.Core/Application/Entity/ApplicationBase.cs b/ds-wms-service/DS.WMS.Core/Application/Entity/ApplicationBase.cs index 7f51624e..c672998c 100644 --- a/ds-wms-service/DS.WMS.Core/Application/Entity/ApplicationBase.cs +++ b/ds-wms-service/DS.WMS.Core/Application/Entity/ApplicationBase.cs @@ -110,13 +110,6 @@ namespace DS.WMS.Core.Application.Entity [SugarColumn(ColumnDescription = "驳回原因", Length = 200, IsNullable = true)] public string? Reason { get; set; } - /// - /// 工作流ID - /// - [SugarColumn(ColumnDescription = "工作流ID", IsNullable = true)] - public long? FlowId { get; set; } - - /// /// 是否已打印 /// diff --git a/ds-wms-service/DS.WMS.Core/Application/Method/ApplicationAuditService`1.cs b/ds-wms-service/DS.WMS.Core/Application/Method/ApplicationAuditService`1.cs index b9f207e4..6b4d3c3c 100644 --- a/ds-wms-service/DS.WMS.Core/Application/Method/ApplicationAuditService`1.cs +++ b/ds-wms-service/DS.WMS.Core/Application/Method/ApplicationAuditService`1.cs @@ -13,10 +13,14 @@ namespace DS.WMS.Core.Application.Method /// /// 申请单审核服务 /// - public class ApplicationAuditService : FeeServiceBase, IApplicationAuditService + public abstract class ApplicationAuditService : FeeServiceBase, IApplicationAuditService where TEntity : ApplicationForm, new() { - internal static readonly TaskBaseTypeEnum[] AuditTypes = [TaskBaseTypeEnum.APPLICATION_PAYMENT_AUDIT]; + /// + /// 适用于当前申请单的审核类型 + /// + public abstract TaskBaseTypeEnum AuditType { get; } + readonly IClientFlowInstanceService flowService; /// @@ -36,7 +40,7 @@ namespace DS.WMS.Core.Application.Method /// public async Task AuditAsync(int yesOrNo, string? remark) { - var recordIds = await GetCurrentFlowsQuery(AuditTypes).Select(x => x.BusinessId).ToArrayAsync(); + var recordIds = await GetCurrentFlowsQuery([AuditType]).Select(x => x.BusinessId).ToArrayAsync(); //没有待审批的列表直接返回不再执行后续查询 if (recordIds.Length == 0) return DataResult.FailedWithDesc(nameof(MultiLanguageConst.NoAuditItems)); @@ -55,49 +59,34 @@ namespace DS.WMS.Core.Application.Method { Id = x.Id, ApplicationNO = x.ApplicationNO, - Status = x.Status, - FlowId = x.FlowId + Status = x.Status }).ToListAsync(); if (apps.Count == 0) return DataResult.FailedWithDesc(nameof(MultiLanguageConst.EmptyData)); - if (apps.Exists(x => !x.FlowId.HasValue)) - return DataResult.FailedWithDesc(nameof(MultiLanguageConst.NotInFlows)); - var result = PreAudit(apps); if (!result.Succeeded) return result; - var flowIds = apps.Select(x => x.FlowId.GetValueOrDefault()); - var flows = await Db.Queryable().Where(x => flowIds.Contains(x.Id)).ToListAsync(); - if (flows.Count == 0) + var flows = await flowService.GetInstanceByBSIdAsync(AuditType, null, request.Ids); + if (flows.Count != request.Ids.Length) return DataResult.FailedWithDesc(nameof(MultiLanguageConst.FlowNotFound)); - if (flows.Exists(x => !x.MakerList.Contains(User.UserId))) - return DataResult.FailedWithDesc(nameof(MultiLanguageConst.AuditUnauthorization)); - List list = []; - foreach (var app in apps) + foreach (var item in flows) { - var flow = flows.Find(x => x.Id == app.FlowId.Value); - if (flow == null) - continue; - result = flowService.AuditFlowInstance(new FlowAuditInfo { - Instance = flow, + Instance = item, Status = request.Result, AuditNote = request.Remark }); if (!result.Succeeded) - list.Add(app.ApplicationNO); + return result; } - if (list.Count > 0) - return DataResult.Failed($"{MultiLanguageConst.Operation_Failed}:{string.Join("、", list)}"); - return DataResult.Success; } @@ -199,8 +188,7 @@ namespace DS.WMS.Core.Application.Method x.AuditerId, x.AuditerName, x.AuditTime, - x.Reason, - x.FlowId + x.Reason }).ExecuteCommandAsync(); } } diff --git a/ds-wms-service/DS.WMS.Core/Application/Method/ApplicationService`1.cs b/ds-wms-service/DS.WMS.Core/Application/Method/ApplicationService`1.cs index b2fced98..42fa31b9 100644 --- a/ds-wms-service/DS.WMS.Core/Application/Method/ApplicationService`1.cs +++ b/ds-wms-service/DS.WMS.Core/Application/Method/ApplicationService`1.cs @@ -9,6 +9,8 @@ using DS.WMS.Core.Fee.Method; using DS.WMS.Core.Flow.Dtos; using DS.WMS.Core.Flow.Entity; using DS.WMS.Core.Flow.Interface; +using DS.WMS.Core.Op.Dtos.TaskInteraction; +using DS.WMS.Core.Op.Interface.TaskInteraction; using DS.WMS.Core.Sys.Interface; using Microsoft.Extensions.DependencyInjection; using SqlSugar; @@ -24,6 +26,7 @@ namespace DS.WMS.Core.Application.Method { readonly IClientFlowInstanceService flowService; readonly Lazy commonService; + readonly ITaskService taskService; /// /// 初始化 @@ -33,6 +36,7 @@ namespace DS.WMS.Core.Application.Method { flowService = serviceProvider.GetRequiredService(); commonService = new Lazy(serviceProvider.GetRequiredService()); + taskService = serviceProvider.GetRequiredService(); } #region 保存 @@ -400,33 +404,57 @@ namespace DS.WMS.Core.Application.Method if (!result.Succeeded) return result; - var template = await FindTemplateAsync(auditType); - if (template == null) - return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TemplateNotFound)); - + List entities = new List(idArray.Length); + bool hasAuthorized = await taskService.HasAuthorizedAsync(); await TenantDb.Ado.BeginTranAsync(); try { - var list2 = list.Select(x => new TEntity { Id = x.Id, Status = x.Status }).ToList(); - foreach (var item in list2) + if (hasAuthorized) { - result = flowService.CreateFlowInstance(new CreateFlowInstanceReq + for (int i = 0; i < idArray.Length; i++) { - BusinessId = item.Id, - TemplateId = template.Id - }); + var req = new TaskCreationRequest + { + BusinessId = idArray[i], + TaskTypeName = auditType.ToString() + }; + result = await taskService.CreateTaskAsync(req); + + if (result.Succeeded) + { + var entity = new TEntity { Id = req.BusinessId }; + OnSubmitApproval(entity); + entities.Add(entity); + } + } + } + else + { + var template = await FindTemplateAsync(auditType); + if (template == null) + return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TemplateNotFound)); - if (result.Succeeded) + var list2 = list.Select(x => new TEntity { Id = x.Id, Status = x.Status }).ToList(); + foreach (var item in list2) { - var instance = result.Data as FlowInstance; - flowService.StartFlowInstance(instance.Id.ToString()); - - item.FlowId = instance.Id; - OnSubmitApproval(item); - await TenantDb.Updateable(item).UpdateColumns(x => new { x.Status, x.FlowId }).ExecuteCommandAsync(); + result = flowService.CreateFlowInstance(new CreateFlowInstanceReq + { + BusinessId = item.Id, + TemplateId = template.Id + }); + + if (result.Succeeded) + { + var instance = result.Data as FlowInstance; + flowService.StartFlowInstance(instance.Id.ToString()); + + OnSubmitApproval(item); + entities.Add(item); + } } } + await TenantDb.Updateable(entities).UpdateColumns(x => new { x.Status }).ExecuteCommandAsync(); await TenantDb.Ado.CommitTranAsync(); return DataResult.Success; } @@ -469,33 +497,29 @@ namespace DS.WMS.Core.Application.Method { Id = x.Id, ApplicationNO = x.ApplicationNO, - Status = x.Status, - FlowId = x.FlowId + Status = x.Status }).ToListAsync(); if (list.Count == 0) return DataResult.FailedWithDesc(nameof(MultiLanguageConst.EmptyData)); + //未在审批状态中 - var list2 = list.FindAll(x => x.FlowId == null).ToList(); - if (list2.Count > 0) - { - string msg = string.Join("; ", list2.Select(x => $"{x.ApplicationNO}")); - return DataResult.Failed(string.Format(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.NoNeedWithdraw)), msg)); - } + if (!await flowService.Exists(ids: ids)) + return DataResult.FailedWithDesc(nameof(MultiLanguageConst.NotInAudit)); - var flows = list.Select(x => new FlowInstance { Id = x.FlowId.Value, FlowStatus = FlowStatusEnum.Draft, MakerList = string.Empty }).ToList(); - DateTime dtNow = DateTime.Now; + DataResult result; try { - await Db.Updateable(flows).UpdateColumns(x => new { x.FlowStatus, x.MakerList }).ExecuteCommandAsync(); + result = await flowService.WithdrawAsync(ids); + if (!result.Succeeded) + return result; foreach (var item in list) { OnWithdraw(item); - item.FlowId = null; } - await TenantDb.Updateable(list).UpdateColumns(x => new { x.Status, x.FlowId }).ExecuteCommandAsync(); + await TenantDb.Updateable(list).UpdateColumns(x => new { x.Status }).ExecuteCommandAsync(); await TenantDb.Ado.CommitTranAsync(); return DataResult.Success; diff --git a/ds-wms-service/DS.WMS.Core/Application/Method/InvoiceApplicationAuditService.cs b/ds-wms-service/DS.WMS.Core/Application/Method/InvoiceApplicationAuditService.cs index 56f7a250..5745583c 100644 --- a/ds-wms-service/DS.WMS.Core/Application/Method/InvoiceApplicationAuditService.cs +++ b/ds-wms-service/DS.WMS.Core/Application/Method/InvoiceApplicationAuditService.cs @@ -18,6 +18,8 @@ namespace DS.WMS.Core.Application.Method /// public class InvoiceApplicationAuditService : ApplicationAuditService, IInvoiceApplicationAuditService { + public override TaskBaseTypeEnum AuditType => TaskBaseTypeEnum.APPLICATION_INVOICE_AUDIT; + /// /// 初始化 /// diff --git a/ds-wms-service/DS.WMS.Core/Application/Method/InvoiceApplicationService.cs b/ds-wms-service/DS.WMS.Core/Application/Method/InvoiceApplicationService.cs index c484e93c..2ae19a91 100644 --- a/ds-wms-service/DS.WMS.Core/Application/Method/InvoiceApplicationService.cs +++ b/ds-wms-service/DS.WMS.Core/Application/Method/InvoiceApplicationService.cs @@ -285,6 +285,7 @@ namespace DS.WMS.Core.Application.Method { Id = a.Id, ApplicationNO = a.ApplicationNO, + AutualCustomerName = a.AutualCustomerName, Currency = a.Currency, CustomerId = a.CustomerId, CustomerName = a.CustomerName, @@ -298,6 +299,7 @@ namespace DS.WMS.Core.Application.Method InvoiceBillNO = a.InvoiceBillNO, InvoiceRemark = a.InvoiceRemark, SaleDeptId = a.SaleDeptId, + TaxID = a.TaxID, Note = a.Note, ApplyAmount = a.ApplyAmount, OtherCurrencyAmount = a.OtherCurrencyAmount, diff --git a/ds-wms-service/DS.WMS.Core/Application/Method/PaymentApplicationAuditService.cs b/ds-wms-service/DS.WMS.Core/Application/Method/PaymentApplicationAuditService.cs index 5cfbcd75..c4098efe 100644 --- a/ds-wms-service/DS.WMS.Core/Application/Method/PaymentApplicationAuditService.cs +++ b/ds-wms-service/DS.WMS.Core/Application/Method/PaymentApplicationAuditService.cs @@ -15,10 +15,12 @@ using SqlSugar; namespace DS.WMS.Core.Application.Method { /// - /// 费用申请单审核服务 + /// 付费申请审核服务 /// public class PaymentApplicationAuditService : ApplicationAuditService, IPaymentApplicationAuditService { + public override TaskBaseTypeEnum AuditType => TaskBaseTypeEnum.APPLICATION_PAYMENT_AUDIT; + /// /// 初始化 /// @@ -51,7 +53,7 @@ namespace DS.WMS.Core.Application.Method break; case AuditStatusForQuery.MarkerOnly: - var ids = await GetCurrentFlowsQuery(AuditTypes).Select(x => x.BusinessId).ToListAsync(); + var ids = await GetCurrentFlowsQuery([AuditType]).Select(x => x.BusinessId).ToListAsync(); if (ids.Count == 0) ids.Add(0L); query = query.Where(x => ids.Contains(x.Id)); diff --git a/ds-wms-service/DS.WMS.Core/Fee/Method/FeeAuditService.cs b/ds-wms-service/DS.WMS.Core/Fee/Method/FeeAuditService.cs index f4a59cca..7bdbbfa0 100644 --- a/ds-wms-service/DS.WMS.Core/Fee/Method/FeeAuditService.cs +++ b/ds-wms-service/DS.WMS.Core/Fee/Method/FeeAuditService.cs @@ -15,7 +15,6 @@ using DS.WMS.Core.Sys.Entity; using Mapster; using Microsoft.Extensions.DependencyInjection; using SqlSugar; -using static AnyDiff.DifferenceLines; namespace DS.WMS.Core.Fee.Method { diff --git a/ds-wms-service/DS.WMS.Core/Info/Entity/InfoClient.cs b/ds-wms-service/DS.WMS.Core/Info/Entity/InfoClient.cs index c6c1a390..fc1778c0 100644 --- a/ds-wms-service/DS.WMS.Core/Info/Entity/InfoClient.cs +++ b/ds-wms-service/DS.WMS.Core/Info/Entity/InfoClient.cs @@ -56,8 +56,8 @@ public class InfoClient : SharedOrgModel /// /// Desc:邮箱 /// - [SugarColumn(ColumnDescription = "邮箱", Length = 50)] - public string Email { get; set; } + [SugarColumn(ColumnDescription = "邮箱", IsNullable = true, Length = 50)] + public string? Email { get; set; } /// /// Desc:网页 diff --git a/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/TaskMailService.cs b/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/TaskMailService.cs index 4de9dc2e..639200cf 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/TaskMailService.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Method/TaskInteraction/TaskMailService.cs @@ -91,10 +91,10 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction foreach (var item in list) item.TaskMailId = taskMail.Id; - //await TenantDb.Deleteable().Where(x => x.TaskMailId == taskMail.Id).ExecuteCommandAsync(); - //await TenantDb.Insertable(taskMail.Attachments).ExecuteCommandAsync(); + await TenantDb.Deleteable().Where(x => x.TaskMailId == taskMail.Id).ExecuteCommandAsync(); + await TenantDb.Insertable(taskMail.Attachments).ExecuteCommandAsync(); - await TenantDb.Storageable(taskMail.Attachments).DefaultAddElseUpdate().ExecuteCommandAsync(); + //await TenantDb.Storageable(taskMail.Attachments).DefaultAddElseUpdate().ExecuteCommandAsync(); } await TenantDb.Ado.CommitTranAsync(); diff --git a/ds-wms-service/DS.WMS.OpApi/DS.WMS.OpApi.csproj.user b/ds-wms-service/DS.WMS.OpApi/DS.WMS.OpApi.csproj.user index 21e5222f..fb7be066 100644 --- a/ds-wms-service/DS.WMS.OpApi/DS.WMS.OpApi.csproj.user +++ b/ds-wms-service/DS.WMS.OpApi/DS.WMS.OpApi.csproj.user @@ -1,7 +1,7 @@  - D:\Code\ds8-solution-pro\ds-wms-service\DS.WMS.OpApi\Properties\PublishProfiles\FolderProfile.pubxml + D:\Source\Repos\DS8\ds-wms-service\DS.WMS.OpApi\Properties\PublishProfiles\FolderProfile.pubxml MvcControllerEmptyScaffolder root/Common/MVC/Controller