|
|
@ -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;
|
|
|
|