邮件模板增加共享

usertest
嵇文龙 3 months ago
parent 06b120b319
commit 547bf3ae02

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

@ -8,7 +8,7 @@ namespace DS.WMS.Core.Op.Entity.TaskInteraction
/// 任务邮件发送配置
/// </summary>
[SugarTable("business_task_mail", "任务邮件发送配置")]
public class BusinessTaskMail : BaseOrgModelV2<long>
public class BusinessTaskMail : SharedOrgModel<long>
{
/// <summary>
/// 单据类型

@ -10,6 +10,12 @@ namespace DS.WMS.Core.Op.Interface.TaskInteraction
/// </summary>
public interface ITaskService
{
/// <summary>
/// 返回任务交互模块是否已授权
/// </summary>
/// <returns>如果已授权则为<c>true</c>,否则为<c>false</c></returns>
Task<bool> HasAuthorized();
/// <summary>
/// 获取业务的任务信息
/// </summary>

@ -49,11 +49,10 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
return val >= 200 && val <= 399;
}
static TaskService()
{
var dic = EnumExt.GetDictionary(typeof(TaskBaseTypeEnum));
var enumValues = dic.GroupBy(x => Math.Abs(x.Key)).Select(x => new
var enumValues = dic.Where(x => x.Key != -1).GroupBy(x => Math.Abs(x.Key)).Select(x => new
{
Value = x.Key,
Count = x.Count()
@ -138,7 +137,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
/// <returns></returns>
public async Task<DataResult> CreateTaskAsync(TaskCreationRequest request, bool useTransaction = true)
{
if (!await EnsureModuleAuthorized())
if (!await HasAuthorized())
return DataResult.SuccessedWithDesc(nameof(MultiLanguageConst.ModuleUnauthorized));
if (request.HasCabin.GetValueOrDefault() && request.BusinessType.HasValue)
@ -347,7 +346,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
/// <returns></returns>
public async Task<DataResult> SetTaskStatusAsync(TaskUpdateRequest request, bool useTransaction = true)
{
if (!await EnsureModuleAuthorized())
if (!await HasAuthorized())
return DataResult.SuccessedWithDesc(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.ModuleUnauthorized)));
if (useTransaction)
@ -469,10 +468,10 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
}
/// <summary>
/// 确保任务交互模块已授权
/// 返回任务交互模块是否已授权
/// </summary>
/// <returns></returns>
protected virtual async Task<bool> EnsureModuleAuthorized()
public virtual async Task<bool> HasAuthorized()
{
long tid = long.Parse(User.TenantId);
var authStr = await Db.Queryable<SysTenantPermissionAuth>().ClearFilter(typeof(ITenantId)).Where(x => x.PermissionId == PERMISSION_ID && x.TenantId == tid &&
@ -894,7 +893,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
/// <returns></returns>
public async Task<DataResult> Delete(long id, BusinessType businessType, string? remark = null, params TaskBaseTypeEnum[] taskTypes)
{
if (!await EnsureModuleAuthorized())
if (!await HasAuthorized())
return DataResult.SuccessedWithDesc(nameof(MultiLanguageConst.ModuleUnauthorized));
string[]? typeNames = taskTypes?.Select(x => x.ToString()).ToArray();

Loading…
Cancel
Save