|
|
|
@ -6,6 +6,7 @@ using DS.WMS.Core.Check.Entity;
|
|
|
|
|
using DS.WMS.Core.Fee.Dtos;
|
|
|
|
|
using DS.WMS.Core.Fee.Entity;
|
|
|
|
|
using DS.WMS.Core.Flow.Dtos;
|
|
|
|
|
using DS.WMS.Core.Flow.Entity;
|
|
|
|
|
using DS.WMS.Core.Flow.Interface;
|
|
|
|
|
using DS.WMS.Core.Info.Dtos;
|
|
|
|
|
using DS.WMS.Core.Info.Entity;
|
|
|
|
@ -68,36 +69,59 @@ public class ClientInfoService : ServiceBase, IClientInfoService
|
|
|
|
|
if (template == null)
|
|
|
|
|
return DataResult.FailedWithDesc(MultiLanguageConst.TemplateNotFound);
|
|
|
|
|
|
|
|
|
|
var requests = list.Select(x => new TaskCreationRequest
|
|
|
|
|
if (await taskService.Value.HasAuthorized())
|
|
|
|
|
{
|
|
|
|
|
BusinessId = x.Id,
|
|
|
|
|
TaskTypeName = INFO_CLIENT_TASK.ToString(),
|
|
|
|
|
TaskTitle = $"【{INFO_CLIENT_TASK.GetDescription()}】{x.CodeName} {x.ShortName}"
|
|
|
|
|
});
|
|
|
|
|
var requests = list.Select(x => new TaskCreationRequest
|
|
|
|
|
{
|
|
|
|
|
BusinessId = x.Id,
|
|
|
|
|
TaskTypeName = INFO_CLIENT_TASK.ToString(),
|
|
|
|
|
TaskTitle = $"【{INFO_CLIENT_TASK.GetDescription()}】{x.CodeName} {x.ShortName}"
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
await TenantDb.Ado.BeginTranAsync();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
DataResult result;
|
|
|
|
|
foreach (var request in requests)
|
|
|
|
|
await TenantDb.Ado.BeginTranAsync();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
result = await taskService.Value.CreateTaskAsync(request, false);
|
|
|
|
|
if (!result.Succeeded)
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
DataResult result;
|
|
|
|
|
foreach (var request in requests)
|
|
|
|
|
{
|
|
|
|
|
result = await taskService.Value.CreateTaskAsync(request, false);
|
|
|
|
|
if (!result.Succeeded)
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await TenantDb.Updateable<InfoClient>().Where(x => idModel.Ids.Contains(x.Id))
|
|
|
|
|
.SetColumns(x => x.AuditStatus == AuditStatusEnum.Auditing).ExecuteCommandAsync();
|
|
|
|
|
await TenantDb.Updateable<InfoClient>().Where(x => idModel.Ids.Contains(x.Id))
|
|
|
|
|
.SetColumns(x => x.AuditStatus == AuditStatusEnum.Auditing).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
await TenantDb.Ado.CommitTranAsync();
|
|
|
|
|
return DataResult.Success;
|
|
|
|
|
await TenantDb.Ado.CommitTranAsync();
|
|
|
|
|
return DataResult.Success;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
await TenantDb.Ado.RollbackTranAsync();
|
|
|
|
|
await ex.LogAsync(Db);
|
|
|
|
|
return DataResult.FailedWithDesc(MultiLanguageConst.Operation_Failed);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < idModel.Ids.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
await TenantDb.Ado.RollbackTranAsync();
|
|
|
|
|
await ex.LogAsync(Db);
|
|
|
|
|
return DataResult.FailedWithDesc(MultiLanguageConst.Operation_Failed);
|
|
|
|
|
var id = idModel.Ids[i];
|
|
|
|
|
var result = flowService.Value.CreateFlowInstance(new CreateFlowInstanceReq
|
|
|
|
|
{
|
|
|
|
|
BusinessId = id,
|
|
|
|
|
TemplateId = template.Id
|
|
|
|
|
});
|
|
|
|
|
if (!result.Succeeded || result.Data is not FlowInstance instance)
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
|
|
result = flowService.Value.StartFlowInstance(instance.Id.ToString());
|
|
|
|
|
if (!result.Succeeded)
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var rows = await TenantDb.Updateable<InfoClient>().Where(x => idModel.Ids.Contains(x.Id))
|
|
|
|
|
.SetColumns(x => x.AuditStatus == AuditStatusEnum.Auditing).ExecuteCommandAsync();
|
|
|
|
|
return rows > 0 ? DataResult.Success : DataResult.FailedWithDesc(MultiLanguageConst.Operation_Failed);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -107,13 +131,86 @@ public class ClientInfoService : ServiceBase, IClientInfoService
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<DataResult> AuditAsync(AuditRequest request)
|
|
|
|
|
{
|
|
|
|
|
return await taskService.Value.AuditAsync(new TaskAuditRequest
|
|
|
|
|
if (await taskService.Value.HasAuthorized())
|
|
|
|
|
{
|
|
|
|
|
Ids = request.Ids,
|
|
|
|
|
Remark = request.Remark,
|
|
|
|
|
Result = request.Result,
|
|
|
|
|
TaskTypeName = INFO_CLIENT_TASK.ToString()
|
|
|
|
|
});
|
|
|
|
|
return await taskService.Value.AuditAsync(new TaskAuditRequest
|
|
|
|
|
{
|
|
|
|
|
Ids = request.Ids,
|
|
|
|
|
Remark = request.Remark,
|
|
|
|
|
Result = request.Result,
|
|
|
|
|
TaskTypeName = INFO_CLIENT_TASK.ToString()
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var list = await flowService.Value.GetInstanceByBSIdAsync(INFO_CLIENT_TASK, ids: request.Ids);
|
|
|
|
|
if (list.Count != request.Ids.Length)
|
|
|
|
|
return DataResult.FailedWithDesc(MultiLanguageConst.NotInAudit);
|
|
|
|
|
|
|
|
|
|
foreach (var item in list)
|
|
|
|
|
{
|
|
|
|
|
var result = flowService.Value.AuditFlowInstance(new FlowAuditInfo
|
|
|
|
|
{
|
|
|
|
|
AuditNote = request.Remark,
|
|
|
|
|
Status = request.Result,
|
|
|
|
|
Instance = item
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (!result.Succeeded)
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return DataResult.Success;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 撤销审核
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="idModel"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<DataResult> WithdrawAsync(IdModel idModel)
|
|
|
|
|
{
|
|
|
|
|
DataResult result;
|
|
|
|
|
if (await taskService.Value.HasAuthorized())
|
|
|
|
|
{
|
|
|
|
|
await TenantDb.Ado.BeginTranAsync();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < idModel.Ids.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
result = await taskService.Value.WithdrawAsync(new TaskRequest
|
|
|
|
|
{
|
|
|
|
|
BusinessId = idModel.Ids[i],
|
|
|
|
|
TaskTypeName = INFO_CLIENT_TASK.ToString()
|
|
|
|
|
}, false);
|
|
|
|
|
if (!result.Succeeded)
|
|
|
|
|
{
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await TenantDb.Updateable<InfoClient>().Where(x => idModel.Ids.Contains(x.Id))
|
|
|
|
|
.SetColumns(x => x.AuditStatus == AuditStatusEnum.NoAudit).ExecuteCommandAsync();
|
|
|
|
|
await TenantDb.Ado.CommitTranAsync();
|
|
|
|
|
return DataResult.Success;
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
await TenantDb.Ado.RollbackTranAsync();
|
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var list = await flowService.Value.GetInstanceByBSIdAsync(INFO_CLIENT_TASK, ids: idModel.Ids);
|
|
|
|
|
if (list.Count != idModel.Ids.Length)
|
|
|
|
|
return DataResult.FailedWithDesc(MultiLanguageConst.NotInAudit);
|
|
|
|
|
|
|
|
|
|
result = await flowService.Value.WithdrawAsync(idModel.Ids);
|
|
|
|
|
if (!result.Succeeded)
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
|
|
int rows = await TenantDb.Updateable<InfoClient>().Where(x => idModel.Ids.Contains(x.Id))
|
|
|
|
|
.SetColumns(x => x.AuditStatus == AuditStatusEnum.NoAudit).ExecuteCommandAsync();
|
|
|
|
|
return rows > 0 ? DataResult.Success : DataResult.FailedWithDesc(MultiLanguageConst.Operation_Failed);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -145,42 +242,6 @@ public class ClientInfoService : ServiceBase, IClientInfoService
|
|
|
|
|
return rows > 0 ? DataResult.Success : DataResult.FailedWithDesc(MultiLanguageConst.Operation_Failed);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 撤销审核
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="idModel"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<DataResult> WithdrawAsync(IdModel idModel)
|
|
|
|
|
{
|
|
|
|
|
DataResult result;
|
|
|
|
|
await TenantDb.Ado.BeginTranAsync();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < idModel.Ids.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
result = await taskService.Value.WithdrawAsync(new TaskRequest
|
|
|
|
|
{
|
|
|
|
|
BusinessId = idModel.Ids[i],
|
|
|
|
|
TaskTypeName = INFO_CLIENT_TASK.ToString()
|
|
|
|
|
}, false);
|
|
|
|
|
if (!result.Succeeded)
|
|
|
|
|
{
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await TenantDb.Updateable<InfoClient>().Where(x => idModel.Ids.Contains(x.Id))
|
|
|
|
|
.SetColumns(x => x.AuditStatus == AuditStatusEnum.NoAudit).ExecuteCommandAsync();
|
|
|
|
|
await TenantDb.Ado.CommitTranAsync();
|
|
|
|
|
return DataResult.Success;
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
await TenantDb.Ado.RollbackTranAsync();
|
|
|
|
|
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 列表
|
|
|
|
|
/// </summary>
|
|
|
|
|