zhangxiaofeng 3 months ago
commit 82e4eba7f2

@ -1,5 +1,4 @@
using System.Runtime.Serialization; using DS.Module.Core.Extensions;
using DS.Module.Core.Extensions;
namespace DS.WMS.Core.Application.Dtos namespace DS.WMS.Core.Application.Dtos
{ {
@ -98,7 +97,6 @@ namespace DS.WMS.Core.Application.Dtos
/// <summary> /// <summary>
/// 所属分部 /// 所属分部
/// </summary> /// </summary>
[IgnoreDataMember]
public long? SaleDeptId { get; set; } public long? SaleDeptId { get; set; }
/// <summary> /// <summary>

@ -110,13 +110,6 @@ namespace DS.WMS.Core.Application.Entity
[SugarColumn(ColumnDescription = "驳回原因", Length = 200, IsNullable = true)] [SugarColumn(ColumnDescription = "驳回原因", Length = 200, IsNullable = true)]
public string? Reason { get; set; } public string? Reason { get; set; }
/// <summary>
/// 工作流ID
/// </summary>
[SugarColumn(ColumnDescription = "工作流ID", IsNullable = true)]
public long? FlowId { get; set; }
/// <summary> /// <summary>
/// 是否已打印 /// 是否已打印
/// </summary> /// </summary>

@ -13,10 +13,14 @@ namespace DS.WMS.Core.Application.Method
/// <summary> /// <summary>
/// 申请单审核服务 /// 申请单审核服务
/// </summary> /// </summary>
public class ApplicationAuditService<TEntity> : FeeServiceBase, IApplicationAuditService<TEntity> public abstract class ApplicationAuditService<TEntity> : FeeServiceBase, IApplicationAuditService<TEntity>
where TEntity : ApplicationForm, new() where TEntity : ApplicationForm, new()
{ {
internal static readonly TaskBaseTypeEnum[] AuditTypes = [TaskBaseTypeEnum.APPLICATION_PAYMENT_AUDIT]; /// <summary>
/// 适用于当前申请单的审核类型
/// </summary>
public abstract TaskBaseTypeEnum AuditType { get; }
readonly IClientFlowInstanceService flowService; readonly IClientFlowInstanceService flowService;
/// <summary> /// <summary>
@ -36,7 +40,7 @@ namespace DS.WMS.Core.Application.Method
/// <returns></returns> /// <returns></returns>
public async Task<DataResult> AuditAsync(int yesOrNo, string? remark) public async Task<DataResult> 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) if (recordIds.Length == 0)
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.NoAuditItems)); return DataResult.FailedWithDesc(nameof(MultiLanguageConst.NoAuditItems));
@ -55,49 +59,34 @@ namespace DS.WMS.Core.Application.Method
{ {
Id = x.Id, Id = x.Id,
ApplicationNO = x.ApplicationNO, ApplicationNO = x.ApplicationNO,
Status = x.Status, Status = x.Status
FlowId = x.FlowId
}).ToListAsync(); }).ToListAsync();
if (apps.Count == 0) if (apps.Count == 0)
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.EmptyData)); return DataResult.FailedWithDesc(nameof(MultiLanguageConst.EmptyData));
if (apps.Exists(x => !x.FlowId.HasValue))
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.NotInFlows));
var result = PreAudit(apps); var result = PreAudit(apps);
if (!result.Succeeded) if (!result.Succeeded)
return result; return result;
var flowIds = apps.Select(x => x.FlowId.GetValueOrDefault()); var flows = await flowService.GetInstanceByBSIdAsync(AuditType, null, request.Ids);
var flows = await Db.Queryable<FlowInstance>().Where(x => flowIds.Contains(x.Id)).ToListAsync(); if (flows.Count != request.Ids.Length)
if (flows.Count == 0)
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.FlowNotFound)); return DataResult.FailedWithDesc(nameof(MultiLanguageConst.FlowNotFound));
if (flows.Exists(x => !x.MakerList.Contains(User.UserId)))
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.AuditUnauthorization));
List<string> list = []; List<string> 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 result = flowService.AuditFlowInstance(new FlowAuditInfo
{ {
Instance = flow, Instance = item,
Status = request.Result, Status = request.Result,
AuditNote = request.Remark AuditNote = request.Remark
}); });
if (!result.Succeeded) 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; return DataResult.Success;
} }
@ -199,8 +188,7 @@ namespace DS.WMS.Core.Application.Method
x.AuditerId, x.AuditerId,
x.AuditerName, x.AuditerName,
x.AuditTime, x.AuditTime,
x.Reason, x.Reason
x.FlowId
}).ExecuteCommandAsync(); }).ExecuteCommandAsync();
} }
} }

@ -9,6 +9,8 @@ using DS.WMS.Core.Fee.Method;
using DS.WMS.Core.Flow.Dtos; using DS.WMS.Core.Flow.Dtos;
using DS.WMS.Core.Flow.Entity; using DS.WMS.Core.Flow.Entity;
using DS.WMS.Core.Flow.Interface; 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 DS.WMS.Core.Sys.Interface;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using SqlSugar; using SqlSugar;
@ -24,6 +26,7 @@ namespace DS.WMS.Core.Application.Method
{ {
readonly IClientFlowInstanceService flowService; readonly IClientFlowInstanceService flowService;
readonly Lazy<ICommonService> commonService; readonly Lazy<ICommonService> commonService;
readonly ITaskService taskService;
/// <summary> /// <summary>
/// 初始化 /// 初始化
@ -33,6 +36,7 @@ namespace DS.WMS.Core.Application.Method
{ {
flowService = serviceProvider.GetRequiredService<IClientFlowInstanceService>(); flowService = serviceProvider.GetRequiredService<IClientFlowInstanceService>();
commonService = new Lazy<ICommonService>(serviceProvider.GetRequiredService<ICommonService>()); commonService = new Lazy<ICommonService>(serviceProvider.GetRequiredService<ICommonService>());
taskService = serviceProvider.GetRequiredService<ITaskService>();
} }
#region 保存 #region 保存
@ -400,13 +404,36 @@ namespace DS.WMS.Core.Application.Method
if (!result.Succeeded) if (!result.Succeeded)
return result; return result;
List<TEntity> entities = new List<TEntity>(idArray.Length);
bool hasAuthorized = await taskService.HasAuthorizedAsync();
await TenantDb.Ado.BeginTranAsync();
try
{
if (hasAuthorized)
{
for (int i = 0; i < idArray.Length; i++)
{
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); var template = await FindTemplateAsync(auditType);
if (template == null) if (template == null)
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TemplateNotFound)); return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TemplateNotFound));
await TenantDb.Ado.BeginTranAsync();
try
{
var list2 = list.Select(x => new TEntity { Id = x.Id, Status = x.Status }).ToList(); var list2 = list.Select(x => new TEntity { Id = x.Id, Status = x.Status }).ToList();
foreach (var item in list2) foreach (var item in list2)
{ {
@ -421,12 +448,13 @@ namespace DS.WMS.Core.Application.Method
var instance = result.Data as FlowInstance; var instance = result.Data as FlowInstance;
flowService.StartFlowInstance(instance.Id.ToString()); flowService.StartFlowInstance(instance.Id.ToString());
item.FlowId = instance.Id;
OnSubmitApproval(item); OnSubmitApproval(item);
await TenantDb.Updateable(item).UpdateColumns(x => new { x.Status, x.FlowId }).ExecuteCommandAsync(); entities.Add(item);
}
} }
} }
await TenantDb.Updateable(entities).UpdateColumns(x => new { x.Status }).ExecuteCommandAsync();
await TenantDb.Ado.CommitTranAsync(); await TenantDb.Ado.CommitTranAsync();
return DataResult.Success; return DataResult.Success;
} }
@ -469,33 +497,29 @@ namespace DS.WMS.Core.Application.Method
{ {
Id = x.Id, Id = x.Id,
ApplicationNO = x.ApplicationNO, ApplicationNO = x.ApplicationNO,
Status = x.Status, Status = x.Status
FlowId = x.FlowId
}).ToListAsync(); }).ToListAsync();
if (list.Count == 0) if (list.Count == 0)
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.EmptyData)); return DataResult.FailedWithDesc(nameof(MultiLanguageConst.EmptyData));
//未在审批状态中 //未在审批状态中
var list2 = list.FindAll(x => x.FlowId == null).ToList(); if (!await flowService.Exists(ids: ids))
if (list2.Count > 0) return DataResult.FailedWithDesc(nameof(MultiLanguageConst.NotInAudit));
{
string msg = string.Join("; ", list2.Select(x => $"{x.ApplicationNO}"));
return DataResult.Failed(string.Format(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.NoNeedWithdraw)), msg));
}
var flows = list.Select(x => new FlowInstance { Id = x.FlowId.Value, FlowStatus = FlowStatusEnum.Draft, MakerList = string.Empty }).ToList(); DataResult result;
DateTime dtNow = DateTime.Now;
try 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) foreach (var item in list)
{ {
OnWithdraw(item); 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(); await TenantDb.Ado.CommitTranAsync();
return DataResult.Success; return DataResult.Success;

@ -18,6 +18,8 @@ namespace DS.WMS.Core.Application.Method
/// </summary> /// </summary>
public class InvoiceApplicationAuditService : ApplicationAuditService<InvoiceApplication>, IInvoiceApplicationAuditService public class InvoiceApplicationAuditService : ApplicationAuditService<InvoiceApplication>, IInvoiceApplicationAuditService
{ {
public override TaskBaseTypeEnum AuditType => TaskBaseTypeEnum.APPLICATION_INVOICE_AUDIT;
/// <summary> /// <summary>
/// 初始化 /// 初始化
/// </summary> /// </summary>

@ -285,6 +285,7 @@ namespace DS.WMS.Core.Application.Method
{ {
Id = a.Id, Id = a.Id,
ApplicationNO = a.ApplicationNO, ApplicationNO = a.ApplicationNO,
AutualCustomerName = a.AutualCustomerName,
Currency = a.Currency, Currency = a.Currency,
CustomerId = a.CustomerId, CustomerId = a.CustomerId,
CustomerName = a.CustomerName, CustomerName = a.CustomerName,
@ -298,6 +299,7 @@ namespace DS.WMS.Core.Application.Method
InvoiceBillNO = a.InvoiceBillNO, InvoiceBillNO = a.InvoiceBillNO,
InvoiceRemark = a.InvoiceRemark, InvoiceRemark = a.InvoiceRemark,
SaleDeptId = a.SaleDeptId, SaleDeptId = a.SaleDeptId,
TaxID = a.TaxID,
Note = a.Note, Note = a.Note,
ApplyAmount = a.ApplyAmount, ApplyAmount = a.ApplyAmount,
OtherCurrencyAmount = a.OtherCurrencyAmount, OtherCurrencyAmount = a.OtherCurrencyAmount,

@ -15,10 +15,12 @@ using SqlSugar;
namespace DS.WMS.Core.Application.Method namespace DS.WMS.Core.Application.Method
{ {
/// <summary> /// <summary>
/// 申请审核服务 /// 费申请审核服务
/// </summary> /// </summary>
public class PaymentApplicationAuditService : ApplicationAuditService<PaymentApplication>, IPaymentApplicationAuditService public class PaymentApplicationAuditService : ApplicationAuditService<PaymentApplication>, IPaymentApplicationAuditService
{ {
public override TaskBaseTypeEnum AuditType => TaskBaseTypeEnum.APPLICATION_PAYMENT_AUDIT;
/// <summary> /// <summary>
/// 初始化 /// 初始化
/// </summary> /// </summary>
@ -51,7 +53,7 @@ namespace DS.WMS.Core.Application.Method
break; break;
case AuditStatusForQuery.MarkerOnly: 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) if (ids.Count == 0)
ids.Add(0L); ids.Add(0L);
query = query.Where(x => ids.Contains(x.Id)); query = query.Where(x => ids.Contains(x.Id));

@ -15,7 +15,6 @@ using DS.WMS.Core.Sys.Entity;
using Mapster; using Mapster;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using SqlSugar; using SqlSugar;
using static AnyDiff.DifferenceLines;
namespace DS.WMS.Core.Fee.Method namespace DS.WMS.Core.Fee.Method
{ {

@ -56,8 +56,8 @@ public class InfoClient : SharedOrgModel<long>
/// <summary> /// <summary>
/// Desc:邮箱 /// Desc:邮箱
/// </summary> /// </summary>
[SugarColumn(ColumnDescription = "邮箱", Length = 50)] [SugarColumn(ColumnDescription = "邮箱", IsNullable = true, Length = 50)]
public string Email { get; set; } public string? Email { get; set; }
/// <summary> /// <summary>
/// Desc:网页 /// Desc:网页

@ -91,10 +91,10 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
foreach (var item in list) foreach (var item in list)
item.TaskMailId = taskMail.Id; item.TaskMailId = taskMail.Id;
//await TenantDb.Deleteable<BusinessTaskAttachment>().Where(x => x.TaskMailId == taskMail.Id).ExecuteCommandAsync(); await TenantDb.Deleteable<BusinessTaskAttachment>().Where(x => x.TaskMailId == taskMail.Id).ExecuteCommandAsync();
//await TenantDb.Insertable(taskMail.Attachments).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(); await TenantDb.Ado.CommitTranAsync();

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup> <PropertyGroup>
<NameOfLastUsedPublishProfile>D:\Code\ds8-solution-pro\ds-wms-service\DS.WMS.OpApi\Properties\PublishProfiles\FolderProfile.pubxml</NameOfLastUsedPublishProfile> <NameOfLastUsedPublishProfile>D:\Source\Repos\DS8\ds-wms-service\DS.WMS.OpApi\Properties\PublishProfiles\FolderProfile.pubxml</NameOfLastUsedPublishProfile>
<Controller_SelectedScaffolderID>MvcControllerEmptyScaffolder</Controller_SelectedScaffolderID> <Controller_SelectedScaffolderID>MvcControllerEmptyScaffolder</Controller_SelectedScaffolderID>
<Controller_SelectedScaffolderCategoryPath>root/Common/MVC/Controller</Controller_SelectedScaffolderCategoryPath> <Controller_SelectedScaffolderCategoryPath>root/Common/MVC/Controller</Controller_SelectedScaffolderCategoryPath>
</PropertyGroup> </PropertyGroup>

Loading…
Cancel
Save