|
|
@ -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,33 +404,57 @@ namespace DS.WMS.Core.Application.Method
|
|
|
|
if (!result.Succeeded)
|
|
|
|
if (!result.Succeeded)
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
|
|
|
|
|
|
|
|
var template = await FindTemplateAsync(auditType);
|
|
|
|
List<TEntity> entities = new List<TEntity>(idArray.Length);
|
|
|
|
if (template == null)
|
|
|
|
bool hasAuthorized = await taskService.HasAuthorizedAsync();
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TemplateNotFound));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await TenantDb.Ado.BeginTranAsync();
|
|
|
|
await TenantDb.Ado.BeginTranAsync();
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var list2 = list.Select(x => new TEntity { Id = x.Id, Status = x.Status }).ToList();
|
|
|
|
if (hasAuthorized)
|
|
|
|
foreach (var item in list2)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
result = flowService.CreateFlowInstance(new CreateFlowInstanceReq
|
|
|
|
for (int i = 0; i < idArray.Length; i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
BusinessId = item.Id,
|
|
|
|
var req = new TaskCreationRequest
|
|
|
|
TemplateId = template.Id
|
|
|
|
{
|
|
|
|
});
|
|
|
|
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;
|
|
|
|
result = flowService.CreateFlowInstance(new CreateFlowInstanceReq
|
|
|
|
flowService.StartFlowInstance(instance.Id.ToString());
|
|
|
|
{
|
|
|
|
|
|
|
|
BusinessId = item.Id,
|
|
|
|
item.FlowId = instance.Id;
|
|
|
|
TemplateId = template.Id
|
|
|
|
OnSubmitApproval(item);
|
|
|
|
});
|
|
|
|
await TenantDb.Updateable(item).UpdateColumns(x => new { x.Status, x.FlowId }).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
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;
|
|
|
|