任务模块增加任务步骤

dev
嵇文龙 1 month ago
parent 7282e783cd
commit edb156b13b

@ -1554,6 +1554,12 @@ public static class MultiLanguageConst
public const string TaskMailSenderNotNull = "Task_Mail_Sender_Not_Null";
[Description("驳回成功")]
public const string TaskRejected = "Task_Rejected";
[Description("未传入子任务信息")]
public const string SubTaskCannotNull = "Sub_Task_Cannot_Null";
[Description("同一任务的步骤类型不可重复")]
public const string DuplicateStepType = "Duplicate_Step_Type";
[Description("此任务尚有未完成的子任务或前置条件")]
public const string UnfinishedItems = "Unfinished_Items";
#endregion
#region 任务台相关

@ -101,7 +101,9 @@ namespace DS.WMS.Core.Fee.Dtos.Report
/// <summary>
/// 开船日期
/// </summary>
public DateTime? ETD { get; set; }
public string? ETD => ETDValue.HasValue ? ETDValue.Value.ToString("yyyy-MM-dd") : string.Empty;
public DateTime? ETDValue { get; set; }
///// <summary>
///// 预抵日期
@ -219,14 +221,14 @@ namespace DS.WMS.Core.Fee.Dtos.Report
public string StlName { get; set; }
/// <summary>
/// 件数
/// 包装
/// </summary>
public int? PKGS { get; set; }
public string? KindPkgsName { get; set; }
/// <summary>
/// 包装
/// 件数
/// </summary>
public string? KindPkgs { get; set; }
public int? PKGS { get; set; }
/// <summary>
/// 毛重
@ -293,6 +295,29 @@ namespace DS.WMS.Core.Fee.Dtos.Report
/// </summary>
public int ECCU { get; set; }
/// <summary>
/// 船公司
/// </summary>
public string? Carrier { get; set; }
/// <summary>
/// 船名
/// </summary>
public string? Vessel { get; set; }
/// <summary>
/// 航次
/// </summary>
public string? Voyno { get; set; }
/// <summary>
/// 内部航次
/// </summary>
public string? InnerVoyno { get; set; }
/// <summary>
/// 费用统计
/// </summary>
public FeeAuditStatistics Statistics { get; set; }
}

@ -7,6 +7,7 @@ using DS.WMS.Core.Info.Entity;
using DS.WMS.Core.Op.Entity;
using DS.WMS.Core.TaskInteraction.Dtos;
using Masuit.Tools.Systems;
using SqlSugar;
namespace DS.WMS.Core.Fee.Method.ReportProviders
{
@ -28,6 +29,7 @@ namespace DS.WMS.Core.Fee.Method.ReportProviders
.Select((s, c) => new ProfitAccounting
{
CustomerCode = c.CodeName,
ETDValue = s.ETD,
Sale = s.Sale,
Operator = s.OperatorName,
CustomerService = s.CustomerServiceName,

@ -1,4 +1,5 @@
using DS.Module.Core;
using DS.WMS.Core.TaskInteraction.Entity;
namespace DS.WMS.Core.TaskInteraction.Dtos
{

@ -39,11 +39,31 @@ namespace DS.WMS.Core.TaskInteraction.Dtos
/// </summary>
public string TaskTypeName { get; set; } = string.Empty;
/// <summary>
/// 父级ID用于子任务
/// </summary>
public long? ParentId { get; set; }
/// <summary>
/// 父级业务ID用于子任务
/// </summary>
public long? ParentBusinessId { get; set; }
/// <summary>
/// 附加数据(内部使用)
/// </summary>
public object? ExtraData { get; set; }
/// <summary>
/// 是否自动同步更新主任务状态
/// </summary>
public bool AutoSync { get; set; }
/// <summary>
/// 任务步骤
/// </summary>
public List<TaskStepDto>? Steps { get; set; }
/// <summary>
/// 确定当前对象是否有效
/// </summary>

@ -0,0 +1,35 @@
using DS.WMS.Core.TaskInteraction.Entity;
using SqlSugar;
namespace DS.WMS.Core.TaskInteraction.Dtos
{
/// <summary>
/// 任务步骤
/// </summary>
public class TaskStepDto
{
/// <summary>
/// 步骤类型
/// </summary>
[SugarColumn(ColumnDescription = "明细类型")]
public StepType Type { get; set; }
/// <summary>
/// 名称
/// </summary>
[SugarColumn(ColumnDescription = "名称", Length = 50, IsNullable = true)]
public string? Name { get; set; }
/// <summary>
/// 值
/// </summary>
[SugarColumn(ColumnDescription = "值", IsNullable = true)]
public object? Value { get; set; }
/// <summary>
/// 是否已完成
/// </summary>
[SugarColumn(ColumnDescription = "是否已完成")]
public bool IsCompleted { get; set; }
}
}

@ -20,7 +20,7 @@ namespace DS.WMS.Core.TaskInteraction.Entity
/// <summary>
/// 上级任务ID
/// </summary>
[SugarColumn(ColumnDescription = "上级任务ID")]
[SugarColumn(ColumnDescription = "上级任务ID", IsNullable = true)]
public long? ParentId { get; set; }
/// <summary>
@ -35,6 +35,12 @@ namespace DS.WMS.Core.TaskInteraction.Entity
[SugarColumn(ColumnDescription = "业务类型", IsNullable = false)]
public BusinessType? BusinessType { get; set; }
/// <summary>
/// 上级业务ID
/// </summary>
[SugarColumn(ColumnDescription = "上级业务ID", IsNullable = true)]
public long? ParentBusinessId { get; set; }
/// <summary>
/// 任务类型
/// </summary>
@ -101,5 +107,11 @@ namespace DS.WMS.Core.TaskInteraction.Entity
/// </summary>
[SugarColumn(ColumnDescription = "审批驳回理由", Length = 200, IsNullable = true)]
public string? RejectReason { get; set; }
/// <summary>
/// 任务步骤
/// </summary>
[Navigate(NavigateType.OneToMany, nameof(TaskStep.TaskId))]
public List<TaskStep>? Steps { get; set; }
}
}

@ -0,0 +1,147 @@
using System.ComponentModel;
using Newtonsoft.Json;
using SqlSugar;
namespace DS.WMS.Core.TaskInteraction.Entity
{
/// <summary>
/// 任务步骤表
/// </summary>
[SugarTable("business_task_step", "任务步骤表")]
public class TaskStep
{
/// <summary>
/// ID
/// </summary>
[SugarColumn(IsPrimaryKey = true)]
public long Id { get; set; }
/// <summary>
/// 任务ID
/// </summary>
[SugarColumn(ColumnDescription = "任务ID")]
public long TaskId { get; set; }
/// <summary>
/// 步骤类型
/// </summary>
[SugarColumn(ColumnDescription = "明细类型")]
public StepType Type { get; set; }
/// <summary>
/// 名称
/// </summary>
[SugarColumn(ColumnDescription = "名称", Length = 50, IsNullable = true)]
public string? Name { get; set; }
/// <summary>
/// 值
/// </summary>
[SugarColumn(ColumnDescription = "值", IsNullable = true)]
public string? Value { get; set; }
/// <summary>
/// 是否已完成
/// </summary>
[SugarColumn(ColumnDescription = "是否已完成")]
public bool IsCompleted { get; set; }
/// <summary>
/// 排序值
/// </summary>
[SugarColumn(ColumnDescription = "排序值")]
public int SortOrder { get; set; }
/// <summary>
/// 创建人
/// </summary>
[SugarColumn(ColumnDescription = "创建人", IsNullable = false)]
public long CreateBy { get; set; }
/// <summary>
/// 创建时间
/// </summary>
[SugarColumn(ColumnDescription = "创建时间", IsNullable = false)]
public DateTime CreateTime { get; set; }
/// <summary>
/// 更新人
/// </summary>
[SugarColumn(ColumnDescription = "更新人", IsNullable = true)]
public long? UpdateBy { get; set; }
/// <summary>
/// 更新时间
/// </summary>
[SugarColumn(ColumnDescription = "更新时间", IsNullable = true)]
public DateTime? UpdateTime { get; set; }
/// <summary>
/// 返回指定类型的值
/// </summary>
/// <typeparam name="T">值的类型</typeparam>
/// <returns></returns>
public T? GetValue<T>()
{
if (string.IsNullOrEmpty(Value))
return default;
var type = typeof(T);
if (type.IsEnum)
return (T)Enum.Parse(type, Value);
if (!type.IsClass)
return (T)Convert.ChangeType(Value, type);
return JsonConvert.DeserializeObject<T>(Value);
}
/// <summary>
/// 设置值
/// </summary>
/// <param name="value">要设置的值</param>
/// <returns></returns>
public void SetValue(object? value)
{
if (value == null)
return;
var type = value.GetType();
if (type.IsClass && type != typeof(string))
{
Value = JsonConvert.SerializeObject(value);
}
else
{
Value = value.ToString();
}
}
}
/// <summary>
/// 任务步骤类型
/// </summary>
public enum StepType
{
/// <summary>
/// 未指定
/// </summary>
[Description("未指定")]
NotSpecified = 0,
/// <summary>
/// 客户确认
/// </summary>
[Description("客户确认")]
CustomerConfirm = 1,
/// <summary>
/// 国外代理确认
/// </summary>
[Description("国外代理确认")]
ForeignAgentConfirm = 2,
}
}

@ -58,6 +58,14 @@ namespace DS.WMS.Core.TaskInteraction.Interface
/// <returns></returns>
Task<DataResult> SetTaskStatusAsync(TaskUpdateRequest request, bool useTransaction = true);
/// <summary>
/// 设置任务步骤状态
/// </summary>
/// <param name="request"></param>
/// <param name="useTransaction">是否使用事务</param>
/// <returns></returns>
Task<DataResult> SetStepsAsync(TaskRequest request, bool useTransaction = true);
/// <summary>
/// 更新任务台描述
/// </summary>

@ -1,16 +1,19 @@
using DS.WMS.Core.TaskInteraction.Dtos;
using DS.Module.Core;
using DS.WMS.Core.Op.Entity;
using DS.WMS.Core.TaskInteraction.Dtos;
using DS.WMS.Core.TaskInteraction.Entity;
using DS.WMS.Core.TaskInteraction.Interface;
using DS.WMS.Core.TaskPlat.Interface;
using Masuit.Tools.Systems;
using Microsoft.Extensions.DependencyInjection;
namespace DS.WMS.Core.TaskInteraction.Method.ActionExecutor.BLConfirm
{
/// <summary>
/// 分单提单确认
/// 分单提单确认动作
/// </summary>
public class SubBLConfirmActionExecutor : ServiceBase, IActionExecutor
{
ITaskManageBCService bCService;
//ITaskManageBCService bCService;
ISeaExportTaskService taskService;
ITaskLogService logService;
@ -20,7 +23,7 @@ namespace DS.WMS.Core.TaskInteraction.Method.ActionExecutor.BLConfirm
/// <param name="provider"></param>
public SubBLConfirmActionExecutor(IServiceProvider provider) : base(provider)
{
bCService = provider.GetRequiredService<ITaskManageBCService>();
//bCService = provider.GetRequiredService<ITaskManageBCService>();
taskService = provider.GetRequiredService<ISeaExportTaskService>();
logService = provider.GetRequiredService<ITaskLogService>();
}
@ -32,8 +35,77 @@ namespace DS.WMS.Core.TaskInteraction.Method.ActionExecutor.BLConfirm
/// <returns></returns>
public async Task ExecuteAsync(ActionExecutionContext context)
{
//if (await taskService)
//{
//}
var bills = await TenantDb.Queryable<SeaExportBillManage>().Where(x => x.BusinessId == context.TaskInfo.BusinessId)
.Select(x => new
{
x.Id,
x.HBLNO,
x.BillType,
x.Vessel,
x.Voyno,
x.ETD,
}).ToListAsync();
if (bills.Count == 0)
return;
DataResult result;
long userId = long.Parse(User.UserId);
var dtNow = DateTime.Now;
await TenantDb.Ado.BeginTranAsync();
try
{
foreach (var bill in bills)
{
var req = new TaskCreationRequest
{
ParentId = context.TaskInfo.Id,
ParentBusinessId = context.TaskInfo.BusinessId,
BusinessId = bill.Id,
BusinessType = context.TaskInfo.BusinessType,
TaskTypeName = TaskBaseTypeEnum.WAIT_SUB_BILL_CONFIRM.ToString(),
TaskTitle = $"{bill.BillType} {bill.HBLNO} {bill.ETD} {bill.Vessel}|{bill.Voyno}",
Steps = []
};
req.Steps.Add(new TaskStepDto
{
Type = StepType.CustomerConfirm,
Name = StepType.CustomerConfirm.ToString()
});
req.Steps.Add(new TaskStepDto
{
Type = StepType.ForeignAgentConfirm,
Name = StepType.ForeignAgentConfirm.ToString()
});
result = await taskService.CreateTaskAsync(req, false);
if (!result.Succeeded)
{
await logService.WriteLogAsync(new BusinessTask
{
BusinessId = req.BusinessId,
BusinessType = req.BusinessType,
TaskStatus = TaskStatusEnum.Create,
TaskType = req.TaskType,
CreateBy = userId,
CreateTime = dtNow
}, $"创建【{req.TaskType.GetDescription()}】任务时出错:" + result.Message);
return;
}
}
await TenantDb.Ado.CommitTranAsync();
}
catch (Exception ex)
{
await TenantDb.Ado.RollbackTranAsync();
await ex.LogAsync(Db);
}
}
}

@ -433,7 +433,7 @@ namespace DS.WMS.Core.TaskInteraction.Method
SendTo = sendTo,
Title = title,
Body = content,
CCTo = string.Join(",", ccList),
CCTo = string.Join(";", ccList),
ShowName = senderConfig.ShowName.IsNullOrEmpty() ? templateModel.Sender.DisplayName : senderConfig.ShowName,
Account = senderConfig.MailAccount,
senderConfig.Password,

@ -1,5 +1,4 @@
using System.Text;
using System.Threading.Tasks;
using DS.Module.Core;
using DS.Module.Core.Data;
using DS.Module.Core.Helpers;
@ -245,6 +244,9 @@ namespace DS.WMS.Core.TaskInteraction.Method
return result;
}
long userId = long.Parse(User.UserId);
DateTime dtNow = DateTime.Now;
if (useTransaction)
await TenantDb.Ado.BeginTranAsync();
try
@ -355,20 +357,40 @@ namespace DS.WMS.Core.TaskInteraction.Method
task = new BusinessTask
{
ParentId = request.ParentId,
BusinessId = request.BusinessId,
BusinessType = request.BusinessType,
ParentBusinessId = request.ParentBusinessId,
TaskType = request.TaskType,
TaskStatus = TaskStatusEnum.Create,
RecvUsers = string.Join(',', info.Main.RecvUserInfoList.Select(x => x.RecvUserId)) ?? string.Empty,
NextType = request.NextType,
CreateBy = long.Parse(User.UserId),
CreateTime = DateTime.Now
CreateBy = userId,
CreateTime = dtNow
};
if (IsOrderType(request.TaskType) && !task.NextType.HasValue)
task.NextType = await GetNextTypeAsync(task);
await TenantDb.Insertable(task).ExecuteCommandAsync();
if (request.Steps?.Count > 0)
{
if (request.Steps.Where(x => x.Type != StepType.NotSpecified).GroupBy(x => x.Type).Select(x => x.Key).Count() > 1)
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.DuplicateStepType));
var steps = request.Steps.Select(x => new TaskStep
{
TaskId = task.Id,
IsCompleted = x.IsCompleted,
Name = x.Name,
Type = x.Type,
SortOrder = request.Steps.IndexOf(x),
CreateBy = userId,
CreateTime = dtNow
}).ToList();
await TenantDb.Insertable(request.Steps).ExecuteCommandAsync();
}
result = await OnTaskCreated(task);
if (!result.Succeeded)
@ -542,8 +564,14 @@ namespace DS.WMS.Core.TaskInteraction.Method
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskNotExists));
if (task.TaskStatus == TaskStatusEnum.Complete)
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskCompleted));
//if (task.TaskStatus == TaskStatusEnum.Cancel)
// return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskCancelled));
//检查是否有未完成的任务步骤
var steps = await TenantDb.Queryable<TaskStep>().Where(x => x.TaskId == task.Id && !x.IsCompleted)
.Select(x => new { x.Type, x.Name }).ToListAsync();
if (steps.Count > 0)
return DataResult.Failed(
MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.UnfinishedItems)) + "" + string.Join("|", steps.Select(x => x.Type == StepType.NotSpecified ? x.Name : x.Type.GetDescription())),
nameof(MultiLanguageConst.UnfinishedItems));
//触发任务状态变更通知
if (task.TaskStatus != request.TaskStatus)
@ -616,6 +644,102 @@ namespace DS.WMS.Core.TaskInteraction.Method
}
}
/// <summary>
/// 设置任务步骤状态
/// </summary>
/// <param name="request"></param>
/// <param name="useTransaction">是否使用事务</param>
/// <returns></returns>
public async Task<DataResult> SetStepsAsync(TaskRequest request, bool useTransaction = true)
{
if (!await HasAuthorizedAsync())
return DataResult.FailedWithDesc(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.ModuleUnauthorized)));
if (request.Steps == null || request.Steps.Count == 0)
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.SubTaskCannotNull));
if (useTransaction)
await TenantDb.Ado.BeginTranAsync();
try
{
BusinessTask task = await GetQuery(request.BusinessId, request.BusinessType, request.TaskType).FirstAsync();
if (task == null)
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskNotExists));
if (task.TaskStatus == TaskStatusEnum.Complete)
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.TaskCompleted));
var stepTypes = request.Steps.Select(x => x.Type);
var steps = await TenantDb.Queryable<TaskStep>().Where(x => x.TaskId == task.Id && stepTypes.Contains(x.Type))
.Select(x => new TaskStep
{
Id = x.Id,
Type = x.Type,
Name = x.Name,
SortOrder = x.SortOrder
}).ToListAsync();
long userId = long.Parse(User.UserId);
DateTime dtNow = DateTime.Now;
foreach (var item in steps)
{
var reqStep = request.Steps.Find(x => x.Type == item.Type);
if (reqStep == null)
continue;
item.SetValue(reqStep.Value);
item.IsCompleted = reqStep.IsCompleted;
item.UpdateBy = userId;
item.UpdateTime = dtNow;
}
await TenantDb.Updateable(steps).UpdateColumns(x => new
{
x.Value,
x.IsCompleted,
x.UpdateBy,
x.UpdateTime
}).ExecuteCommandAsync();
if (request.AutoSync)
{
var allSteps = await TenantDb.Queryable<TaskStep>().Where(x => x.TaskId == task.Id)
.Select(x => new
{
x.Id,
x.IsCompleted
}).ToListAsync();
if (allSteps.Count > 0 && allSteps.Count == allSteps.Count(x => x.IsCompleted))
{
var result = await SetTaskStatusAsync(new TaskUpdateRequest
{
BusinessId = task.BusinessId,
BusinessType = task.BusinessType,
TaskTypeName = request.TaskTypeName,
TaskStatus = TaskStatusEnum.Complete
}, false);
if (!result.Succeeded)
return result;
}
}
if (useTransaction)
await TenantDb.Ado.CommitTranAsync();
return DataResult.Success;
}
catch (Exception ex)
{
if (useTransaction)
await TenantDb.Ado.RollbackTranAsync();
await ex.LogAsync(Db);
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed));
}
}
/// <summary>
/// 当任务状态发生变化时调用
/// </summary>

@ -84,7 +84,12 @@ namespace DS.WMS.OpApi.Controllers
{
var result = await taskService.GetTasks(request.BusinessId, request.BusinessType, request.TaskType);
if (result.Data?.Count > 0)
return await actionService.TriggerActionAsync(result.Data[0].Adapt<BusinessTask>(), false);
{
var task = result.Data[0].Adapt<BusinessTask>();
task.BusinessId = request.BusinessId;
task.BusinessType = request.BusinessType;
return await actionService.TriggerActionAsync(task, false);
}
return DataResult.FailedWithDesc(MultiLanguageConst.EmptyData);
}
@ -159,6 +164,20 @@ namespace DS.WMS.OpApi.Controllers
return await taskService.SetTaskStatusAsync(request);
}
/// <summary>
/// 设置任务步骤
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost, Route("SetSteps")]
public async Task<DataResult> SetStepsAsync(TaskRequest request)
{
if (!ModelState.IsValid)
return DataResult.Failed(ModelState.GetErrorMessage(), MultiLanguageConst.IllegalRequest);
return await taskService.SetStepsAsync(request);
}
/// <summary>
/// 手动发起任务审核(用于二次审核)
/// </summary>

@ -120,7 +120,7 @@
"Port": 465,
"UseSSL": true,
"Receivers": "candy@sunniness.net",
"CCTo": "yee@sunniness.net,daisusu@dongshengsoft.com",
"CCTo": "yee@sunniness.net;daisusu@dongshengsoft.com",
"Title": "WSL Volume Daily Increase Report",
"Body": "<article class='4ever-article'><p style='line-height: 1;'>Dear WSL Team,</p><p style='line-height: 1;'>Pls kindly check the daily report for your member's nomination booking:&nbsp;</p><p style='line-height: 1;'>&nbsp;</p><p style='line-height: 1;'>Thanks &amp; Best regards</p><p style='line-height: 1;'>Candy SHAO 邵芳</p><p style='line-height: 1;'>General Manager| <strong><span style='color: #e67e23;'>SUNNINESS LOGISTICS CO.,LTD.</span></strong></p><p style='line-height: 1;'>TEL: +(86) (0532-80688387)1 MB./We chat: +(86)(18866622731) | QQ:2853083553|Email:candy@sunniness. net |WCA ID: 60272</p></article>"
}

Loading…
Cancel
Save