临时签入

usertest
嵇文龙 4 months ago
parent 872b7977ab
commit 43e7d8c6ef

@ -1491,6 +1491,11 @@ public static class MultiLanguageConst
public const string TaskAuditStatusError = "Task_Audit_Status_Error";
[Description("无法从配置中获取任务接收人,请联系管理员检查系统配置")]
public const string TaskReceiverNotFound = "Task_Receiver_Not_Found";
[Description("任务邮件必须设置收件人")]
public const string TaskMailReceiverNotNull = "Task_Mail_Receiver_Not_Null";
[Description("任务邮件必须设置发件人")]
public const string TaskMailSenderNotNull = "Task_Mail_Sender_Not_Null";
#endregion
#region 任务台相关

@ -34,5 +34,13 @@
/// BC修改文件
/// </summary>
public const string AmendmentFile = "AmendmentFile";
/// <summary>
/// 任务主表主键
/// </summary>
public const string TaskPkId = "taskPkId";
public const string BusinessTask = "BusinessTask";
}
}

@ -30,6 +30,6 @@ public abstract class BaseOrgModelV2<TKey> : BaseModelV2<TKey>, IOrgId
/// <summary>
/// 机构Id
/// </summary>
[SugarColumn(ColumnDescription = "机构Id")]
[SugarColumn(ColumnDescription = "机构Id", IsOnlyIgnoreUpdate = true)]
public long OrgId { get; set; }
}

@ -0,0 +1,15 @@
using DS.Module.Core.Data;
using DS.WMS.Core.Op.Entity.TaskInteraction;
namespace DS.WMS.Core.Op.Dtos.TaskInteraction
{
/// <summary>
/// 动作执行上下文
/// </summary>
public class ActionExecutionContext
{
public BusinessTask Task { get; set; }
}
}

@ -5,8 +5,8 @@ namespace DS.WMS.Core.Op.Entity.TaskInteraction
/// <summary>
/// 任务邮件附件配置
/// </summary>
[SugarTable("business_task_mail_attachment", "任务邮件附件配置")]
public class BusinessTaskMailAttachment
[SugarTable("business_task_attachment", "任务邮件附件配置")]
public class BusinessTaskAttachment
{
/// <summary>
/// 任务邮件配置ID

@ -105,6 +105,12 @@ namespace DS.WMS.Core.Op.Entity.TaskInteraction
/// 审核
/// </summary>
[Description("审核")]
Audit = 101
Audit = 101,
/// <summary>
/// 邮件服务
/// </summary>
[Description("邮件服务")]
Mail = 201
}
}

@ -8,7 +8,7 @@ namespace DS.WMS.Core.Op.Entity.TaskInteraction
/// 任务邮件发送配置
/// </summary>
[SugarTable("business_task_mail", "任务邮件发送配置")]
public class BusinessTaskMail : BaseModelV2<long>
public class BusinessTaskMail : BaseOrgModelV2<long>
{
/// <summary>
/// 任务类型
@ -16,11 +16,11 @@ namespace DS.WMS.Core.Op.Entity.TaskInteraction
[SugarColumn(ColumnDescription = "任务类型", IsNullable = false)]
public TaskBaseTypeEnum TaskType { get; set; }
/// <summary>
/// 任务状态
/// </summary>
[SugarColumn(ColumnDescription = "任务状态", IsNullable = false)]
public TaskStatusEnum TaskStatus { get; set; }
///// <summary>
///// 任务状态
///// </summary>
//[SugarColumn(ColumnDescription = "任务状态", IsNullable = false)]
//public TaskStatusEnum TaskStatus { get; set; } = TaskStatusEnum.Complete;
/// <summary>
/// 主题
@ -41,10 +41,16 @@ namespace DS.WMS.Core.Op.Entity.TaskInteraction
public string? CustomerName { get; set; }
/// <summary>
/// 机构ID
/// 服务器设置ID
/// </summary>
[SugarColumn(ColumnDescription = "任务类型", IsNullable = false)]
public long ServerId { get; set; }
/// <summary>
/// 服务器设置
/// </summary>
[SugarColumn(ColumnDescription = "机构ID", IsNullable = false)]
public long OrgId { get; set; }
[Navigate(NavigateType.OneToOne, nameof(ServerId))]
public BusinessTaskMailServer? Server { get; set; }
/// <summary>
/// 接收人设置
@ -61,7 +67,7 @@ namespace DS.WMS.Core.Op.Entity.TaskInteraction
/// <summary>
/// 附件设置
/// </summary>
[Navigate(NavigateType.OneToMany, nameof(BusinessTaskMailAttachment.TaskMailId))]
public List<BusinessTaskMailAttachment>? Attachments { get; set; }
[Navigate(NavigateType.OneToMany, nameof(BusinessTaskAttachment.TaskMailId))]
public List<BusinessTaskAttachment>? Attachments { get; set; }
}
}

@ -0,0 +1,42 @@
using DS.Module.Core.Data;
using SqlSugar;
namespace DS.WMS.Core.Op.Entity.TaskInteraction
{
/// <summary>
/// 任务邮件服务器配置
/// </summary>
[SugarTable("business_task_mail_server", "任务邮件服务器配置")]
public class BusinessTaskMailServer : BaseOrgModelV2<long>
{
/// <summary>
/// 服务器地址
/// </summary>
[SugarColumn(ColumnDescription = "服务器地址", Length = 200, IsNullable = false)]
public string Server { get; set; } = string.Empty;
/// <summary>
/// 端口号
/// </summary>
[SugarColumn(ColumnDescription = "端口号")]
public int Port { get; set; }
/// <summary>
/// 使用SSL连接
/// </summary>
[SugarColumn(ColumnDescription = "使用SSL连接", DefaultValue = "1")]
public bool UseSSL { get; set; } = true;
/// <summary>
/// 登录账号
/// </summary>
[SugarColumn(ColumnDescription = "登录账号", Length = 200, IsNullable = true)]
public string? LoginName { get; set; }
/// <summary>
/// 登录密码
/// </summary>
[SugarColumn(ColumnDescription = "登录密码", Length = 200, IsNullable = true)]
public string? Password { get; set; }
}
}

@ -0,0 +1,17 @@
using DS.WMS.Core.Op.Dtos.TaskInteraction;
namespace DS.WMS.Core.Op.Interface.TaskInteraction
{
/// <summary>
/// 动作执行器
/// </summary>
public interface IActionExecutor
{
/// <summary>
/// 执行特定动作
/// </summary>
/// <param name="context"></param>
/// <returns></returns>
Task ExecuteAsync(ActionExecutionContext context);
}
}

@ -0,0 +1,25 @@
using DS.Module.Core.Data;
using DS.WMS.Core.Op.Entity.TaskInteraction;
namespace DS.WMS.Core.Op.Interface.TaskInteraction
{
/// <summary>
/// 动作执行管理
/// </summary>
public interface IActionManager
{
/// <summary>
/// 执行特定动作
/// </summary>
/// <param name="dataContext">数据上下文</param>
/// <returns></returns>
Task ExecuteAsync(TaskFlowDataContext dataContext);
/// <summary>
/// 触发任务执行动作
/// </summary>
/// <param name="businessTask">任务信息</param>
/// <returns></returns>
Task TriggerAction(BusinessTask businessTask);
}
}

@ -1,9 +1,40 @@
namespace DS.WMS.Core.Op.Interface.TaskInteraction
using DS.Module.Core;
using DS.Module.Core.Data;
using DS.WMS.Core.Op.Entity.TaskInteraction;
namespace DS.WMS.Core.Op.Interface.TaskInteraction
{
/// <summary>
/// 邮件配置服务定义
/// </summary>
public interface ITaskMailService
{
/// <summary>
/// 获取分页列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
Task<DataResult<List<BusinessTaskMail>>> GetListAsync(PageRequest request);
/// <summary>
/// 详情
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
Task<DataResult<BusinessTaskMail>> GetAsync(long id);
/// <summary>
/// 编辑
/// </summary>
/// <param name="taskMail"></param>
/// <returns></returns>
Task<DataResult> EditAsync(BusinessTaskMail taskMail);
/// <summary>
/// 删除
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
Task<DataResult> DeleteAsync(IdModel model);
}
}

@ -0,0 +1,45 @@
using DS.Module.Core;
using DS.WMS.Core.Op.Entity.TaskInteraction;
using DS.WMS.Core.Op.Interface.TaskInteraction;
using Microsoft.Extensions.DependencyInjection;
namespace DS.WMS.Core.Op.Method.TaskInteraction
{
public class ActionExecutor : ServiceBase
{
//任务日志服务
//readonly ITaskLogService LogService;
/// <summary>
/// 初始化
/// </summary>
/// <param name="provider"></param>
public ActionExecutor(IServiceProvider provider) : base(provider)
{
//LogService = provider.GetRequiredService<ITaskLogService>();
}
///// <summary>
///// 执行特定任务类型的邮件服务
///// </summary>
///// <param name="task">任务</param>
///// <returns></returns>
///// <exception cref="ArgumentNullException"><paramref name="task"/>为null</exception>
//public async Task<DataResult> ExecuteAsync(BusinessTask task)
//{
// ArgumentNullException.ThrowIfNull(task, nameof(task));
// var list = await TenantDb.Queryable<BusinessTaskMail>().Where(x => x.TaskType == task.TaskType && x.TaskStatus == task.TaskStatus)
// .Select(x => new
// {
// TemplateIds = x.Attachments.Select(x => x.TemplateId),
// x.Receiver,
// x.Sender,
// x.Title,
// x.Content
// }).ToListAsync();
//}
}
}

@ -0,0 +1,69 @@
using DS.Module.Core;
using DS.Module.Core.Data;
using DS.WMS.Core.Op.Entity.TaskInteraction;
using DS.WMS.Core.Op.Interface.TaskInteraction;
using DS.WMS.Core.TaskPlat;
namespace DS.WMS.Core.Op.Method.TaskInteraction
{
/// <summary>
/// 动作执行管理
/// </summary>
public class ActionManager : ServiceBase, IActionManager
{
Dictionary<TaskActionType, IActionExecutor> ExecutorMappings;
/// <summary>
/// 初始化
/// </summary>
public ActionManager(IServiceProvider serviceProvider) : base(serviceProvider)
{
ExecutorMappings = new Dictionary<TaskActionType, IActionExecutor>();
ExecutorMappings[TaskActionType.Mail] = new MailActionExecutor();
}
/// <summary>
/// 触发任务执行动作
/// </summary>
/// <param name="businessTask">任务信息</param>
/// <returns></returns>
public async Task TriggerAction(BusinessTask businessTask)
{
ArgumentNullException.ThrowIfNull(businessTask, nameof(businessTask));
//目前只限制任务完成才触发
if (businessTask.TaskStatus != TaskStatusEnum.Complete)
return;
// 执行自动化操作
TaskFlowDataContext dataContext = new(
(TaskFlowDataNameConst.BusinessTask, businessTask)
);
TaskFlowRuner taskFlow = new(TenantDb, ServiceProvider);
await taskFlow.Run(businessTask.TaskType, businessTask.BusinessId, dataContext);
}
public async Task ExecuteAsync(TaskFlowDataContext dataContext)
{
ArgumentNullException.ThrowIfNull(dataContext, nameof(dataContext));
}
}
/// <summary>
/// 任务执行类型
/// </summary>
public enum TaskActionType
{
/// <summary>
/// 后台任务
/// </summary>
BackgroundWorker,
/// <summary>
/// 邮件
/// </summary>
Mail,
}
}

@ -0,0 +1,13 @@
using DS.WMS.Core.Op.Dtos.TaskInteraction;
using DS.WMS.Core.Op.Interface.TaskInteraction;
namespace DS.WMS.Core.Op.Method.TaskInteraction
{
public class MailActionExecutor : IActionExecutor
{
public Task ExecuteAsync(ActionExecutionContext context)
{
throw new NotImplementedException();
}
}
}

@ -199,7 +199,7 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
if (((JObject)result.data)["ext"] is not JArray extArray || extArray.Count == 0)
return [];
return extArray.Select(x => x["projectName"]?.Value<string>() ?? string.Empty).ToArray();
return extArray.Where(x => x["isYield"].Value<bool>()).Select(x => x["projectName"]?.Value<string>() ?? string.Empty).ToArray();
}
//public override async Task MarkerChangedAsync(MarkerChangedCallback callback)

@ -1,4 +1,5 @@
using DS.Module.Core;
using DS.Module.Core.Data;
using DS.Module.Core.Extensions;
using DS.WMS.Core.Op.Entity.TaskInteraction;
using DS.WMS.Core.Op.Interface.TaskInteraction;
@ -30,36 +31,87 @@ namespace DS.WMS.Core.Op.Method.TaskInteraction
.Where(whereList).ToQueryPageAsync(request.PageCondition);
}
///// <summary>
///// 编辑
///// </summary>
///// <param name="taskMail"></param>
///// <returns></returns>
//public async Task<DataResult> EditAsync(BusinessTaskMail taskMail)
//{
// try
// {
/// <summary>
/// 详情
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public async Task<DataResult<BusinessTaskMail>> GetAsync(long id)
{
var entity = await TenantDb.Queryable<BusinessTaskMail>().Includes(x => x.Receiver).Includes(x => x.Sender)
.Where(x => x.Id == id).FirstAsync();
return DataResult<BusinessTaskMail>.Success(entity);
}
/// <summary>
/// 编辑
/// </summary>
/// <param name="taskMail"></param>
/// <returns></returns>
public async Task<DataResult> EditAsync(BusinessTaskMail taskMail)
{
await TenantDb.Ado.BeginTranAsync();
try
{
if (taskMail.Id == 0)
{
taskMail.Receiver ??= new();
taskMail.Sender ??= new();
// }
// catch (Exception ex)
// {
// await TenantDb.Ado.RollbackTranAsync();
// await ex.LogAsync(Db);
// return DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed));
// }
taskMail = await TenantDb.InsertNav(taskMail).Include(x => x.Receiver).Include(x => x.Sender).ExecuteReturnEntityAsync();
}
else
{
await TenantDb.UpdateNav(taskMail).Include(x => x.Receiver).Include(x => x.Sender).ExecuteCommandAsync();
}
// if (taskMail.Id == 0)
// {
// taskMail.Receiver ??= new();
// taskMail.Sender ??= new();
if (taskMail.Attachments?.Count > 0)
{
var list = taskMail.Attachments.FindAll(x => x.TaskMailId == 0);
foreach (var item in list)
item.TaskMailId = taskMail.Id;
await TenantDb.Deleteable<BusinessTaskAttachment>().Where(x => x.TaskMailId == taskMail.Id).ExecuteCommandAsync();
await TenantDb.Insertable(taskMail.Attachments).ExecuteCommandAsync();
}
await TenantDb.Ado.CommitTranAsync();
return DataResult.Success;
}
catch (Exception ex)
{
await TenantDb.Ado.RollbackTranAsync();
await ex.LogAsync(Db);
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed));
}
}
/// <summary>
/// 删除
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public async Task<DataResult> DeleteAsync(IdModel model)
{
await TenantDb.Ado.BeginTranAsync();
try
{
await TenantDb.DeleteNav<BusinessTaskMail>(x => model.Ids.Contains(x.Id))
.Include(x => x.Receiver).Include(x => x.Sender).Include(x => x.Attachments).ExecuteCommandAsync();
await TenantDb.Ado.CommitTranAsync();
return DataResult.Success;
}
catch (Exception ex)
{
await TenantDb.Ado.RollbackTranAsync();
await ex.LogAsync(Db);
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed));
}
}
// await TenantDb.InsertNav(taskMail).Include(x => x.Receiver).Include(x => x.Sender).ExecuteCommandAsync();
// }
// else
// {
// }
//}
}
}

@ -12,6 +12,10 @@ namespace DS.WMS.Core
/// </summary>
public abstract class ServiceBase
{
/// <summary>
/// 获取服务容器
/// </summary>
protected IServiceProvider ServiceProvider { get; private set; }
/// <summary>
/// 获取用户相关信息
/// </summary>
@ -46,6 +50,7 @@ namespace DS.WMS.Core
/// <param name="serviceProvider">服务提供程序</param>
protected ServiceBase(IServiceProvider serviceProvider)
{
ServiceProvider = serviceProvider;
User = serviceProvider.GetRequiredService<IUser>();
Db = serviceProvider.GetRequiredService<ISqlSugarClient>();
SaasService = serviceProvider.GetRequiredService<ISaasDbService>();

@ -1,6 +1,5 @@
using System.Net;
using DS.Module.Core;
using DS.WMS.Core.Fee.Dtos;
using DS.WMS.Core.Flow.Dtos;
using DS.WMS.Core.Op.Dtos.TaskInteraction;
using DS.WMS.Core.Op.Entity;

@ -0,0 +1,63 @@
using DS.Module.Core;
using DS.WMS.Core.Op.Entity.TaskInteraction;
using DS.WMS.Core.Op.Interface.TaskInteraction;
using Microsoft.AspNetCore.Mvc;
namespace DS.WMS.OpApi.Controllers
{
/// <summary>
/// 任务邮件API
/// </summary>
public class TaskMailController : ApiController
{
readonly ITaskMailService service;
/// <summary>
/// 构造函数
/// </summary>
/// <param name="service"></param>
public TaskMailController(ITaskMailService service)
{
this.service = service;
}
/// <summary>
/// 获取分页列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost, Route("GetList")]
public async Task<DataResult<List<BusinessTaskMail>>> GetListAsync(PageRequest request)
{
return await service.GetListAsync(request);
}
/// <summary>
/// 详情
/// </summary>
/// <param name="id">ID</param>
/// <returns></returns>
[HttpGet, Route("Edit")]
public async Task<DataResult<BusinessTaskMail>>GetAsync(long id)
{
return await service.GetAsync(id);
}
/// <summary>
/// 编辑
/// </summary>
/// <param name="taskMail">邮件配置</param>
/// <returns></returns>
[HttpPost, Route("Edit")]
public async Task<DataResult> EditAsync(BusinessTaskMail taskMail)
{
if (taskMail.Receiver == null)
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskMailReceiverNotNull));
if (taskMail.Sender == null)
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskMailSenderNotNull));
return await service.EditAsync(taskMail);
}
}
}
Loading…
Cancel
Save