|
|
|
@ -1,9 +1,11 @@
|
|
|
|
|
using DS.Module.Core;
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
using DS.Module.Core;
|
|
|
|
|
using DS.Module.Core.Data;
|
|
|
|
|
using DS.Module.Core.Extensions;
|
|
|
|
|
using DS.WMS.Core.TaskInteraction.Entity;
|
|
|
|
|
using DS.WMS.Core.TaskInteraction.Interface;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
|
|
|
|
|
namespace DS.WMS.Core.TaskInteraction.Method
|
|
|
|
|
{
|
|
|
|
@ -74,6 +76,29 @@ namespace DS.WMS.Core.TaskInteraction.Method
|
|
|
|
|
// return DataResult<Tuple<string, string>>.Success(new Tuple<string, string>(title, content));
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取数据提供程序
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="query">查询条件</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<DataResult<List<BusinessDataProvider>>> GetProvidersAsync(string? query)
|
|
|
|
|
{
|
|
|
|
|
List<IConditionalModel> conditionals = [];
|
|
|
|
|
if (!string.IsNullOrEmpty(query))
|
|
|
|
|
conditionals = Db.Utilities.JsonToConditionalModels(query);
|
|
|
|
|
|
|
|
|
|
var list = await TenantDb.Queryable<BusinessDataProvider>()
|
|
|
|
|
.Where(conditionals).ToListAsync();
|
|
|
|
|
|
|
|
|
|
var result = DataResult<List<BusinessDataProvider>>.Success(list);
|
|
|
|
|
result.AdditionalData ??= [];
|
|
|
|
|
var types = Array.FindAll(Assembly.GetExecutingAssembly().GetTypes(),
|
|
|
|
|
x => x.IsClass && typeof(IDataProvider).IsAssignableFrom(x));
|
|
|
|
|
result.AdditionalData["AvailableTypes"] = types.Select(x => x.FullName);
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取分页列表
|
|
|
|
|
/// </summary>
|
|
|
|
@ -83,7 +108,7 @@ namespace DS.WMS.Core.TaskInteraction.Method
|
|
|
|
|
{
|
|
|
|
|
var whereList = request.GetConditionalModels(Db);
|
|
|
|
|
return await TenantDb.Queryable<BusinessTaskMail>()
|
|
|
|
|
.Includes(x => x.Receiver).Includes(x => x.Sender).Includes(x => x.CC)
|
|
|
|
|
.Includes(x => x.Receivers).Includes(x => x.Sender).Includes(x => x.CC)
|
|
|
|
|
.Where(whereList).ToQueryPageAsync(request.PageCondition);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -95,7 +120,7 @@ namespace DS.WMS.Core.TaskInteraction.Method
|
|
|
|
|
public async Task<DataResult<BusinessTaskMail>> GetAsync(long id)
|
|
|
|
|
{
|
|
|
|
|
var entity = await TenantDb.Queryable<BusinessTaskMail>()
|
|
|
|
|
.Includes(x => x.Receiver).Includes(x => x.Sender).Includes(x => x.CC).Includes(x => x.Attachments)
|
|
|
|
|
.Includes(x => x.Receivers).Includes(x => x.Sender).Includes(x => x.CC).Includes(x => x.Attachments)
|
|
|
|
|
.Where(x => x.Id == id).FirstAsync();
|
|
|
|
|
|
|
|
|
|
return DataResult<BusinessTaskMail>.Success(entity);
|
|
|
|
@ -109,7 +134,7 @@ namespace DS.WMS.Core.TaskInteraction.Method
|
|
|
|
|
public async Task<BusinessTaskMail> GetAsync(string name)
|
|
|
|
|
{
|
|
|
|
|
return await TenantDb.Queryable<BusinessTaskMail>()
|
|
|
|
|
.Includes(x => x.Receiver).Includes(x => x.Sender).Includes(x => x.CC).Includes(x => x.Attachments)
|
|
|
|
|
.Includes(x => x.Receivers).Includes(x => x.Sender).Includes(x => x.CC).Includes(x => x.Attachments)
|
|
|
|
|
.Where(x => x.Name.Contains(name)).FirstAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -125,19 +150,25 @@ namespace DS.WMS.Core.TaskInteraction.Method
|
|
|
|
|
{
|
|
|
|
|
if (taskMail.Id == 0)
|
|
|
|
|
{
|
|
|
|
|
taskMail.Receiver ??= new();
|
|
|
|
|
taskMail.Receivers ??= [];
|
|
|
|
|
taskMail.Sender ??= new();
|
|
|
|
|
taskMail.CC ??= new();
|
|
|
|
|
|
|
|
|
|
taskMail = await TenantDb.InsertNav(taskMail)
|
|
|
|
|
.Include(x => x.Receiver).Include(x => x.Sender).Include(x => x.CC)
|
|
|
|
|
.ExecuteReturnEntityAsync();
|
|
|
|
|
taskMail = await TenantDb.InsertNav(taskMail).Include(x => x.Sender).Include(x => x.CC).ExecuteReturnEntityAsync();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
await TenantDb.UpdateNav(taskMail)
|
|
|
|
|
.Include(x => x.Receiver).Include(x => x.Sender).Include(x => x.CC)
|
|
|
|
|
.ExecuteCommandAsync();
|
|
|
|
|
await TenantDb.UpdateNav(taskMail).Include(x => x.Sender).Include(x => x.CC).ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (taskMail.Receivers?.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
var list = taskMail.Receivers.FindAll(x => x.TaskMailId == 0);
|
|
|
|
|
foreach (var item in list)
|
|
|
|
|
item.TaskMailId = taskMail.Id;
|
|
|
|
|
|
|
|
|
|
await TenantDb.Deleteable<BusinessTaskMailReceiver>().Where(x => x.TaskMailId == taskMail.Id).ExecuteCommandAsync();
|
|
|
|
|
await TenantDb.Insertable(taskMail.Receivers).ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (taskMail.Attachments?.Count > 0)
|
|
|
|
@ -148,8 +179,6 @@ namespace DS.WMS.Core.TaskInteraction.Method
|
|
|
|
|
|
|
|
|
|
await TenantDb.Deleteable<BusinessTaskAttachment>().Where(x => x.TaskMailId == taskMail.Id).ExecuteCommandAsync();
|
|
|
|
|
await TenantDb.Insertable(taskMail.Attachments).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
//await TenantDb.Storageable(taskMail.Attachments).DefaultAddElseUpdate().ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await TenantDb.Ado.CommitTranAsync();
|
|
|
|
@ -175,7 +204,7 @@ namespace DS.WMS.Core.TaskInteraction.Method
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
await TenantDb.DeleteNav<BusinessTaskMail>(x => model.Ids.Contains(x.Id))
|
|
|
|
|
.Include(x => x.Receiver).Include(x => x.Sender).Include(x => x.CC).Include(x => x.Attachments)
|
|
|
|
|
.Include(x => x.Receivers).Include(x => x.Sender).Include(x => x.CC).Include(x => x.Attachments)
|
|
|
|
|
.ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
await TenantDb.Ado.CommitTranAsync();
|
|
|
|
|