cjy 2 weeks ago
commit bb5ac8004c

@ -19,4 +19,9 @@ public class ComonConst
/// ApiUserFilter授权方式使用的Header头
/// </summary>
public const string API_USER_HEADER_SECRET = "USER_SECRET";
/// <summary>
/// 任务台日志logger名称
/// </summary>
public const string TASK_FLOW_LOGGER = "TaskFlowLogger";
}

@ -1614,6 +1614,9 @@ public static class MultiLanguageConst
[Description("所选任务中存在非当前登陆人待处理的任务,请检查您是否在以下任务的接收人列表之内,任务流水号:{0}")]
public const string TaskNotHaveAuthor = "TaskNotHaveAuthor";
[Description("任务类型不正确")]
public const string TaskTypeError = "TaskTypeError";
#endregion
#region 邮件解析配置

@ -1,4 +1,6 @@
namespace DS.Module.Core.Enums.TaskPlat
using System.ComponentModel;
namespace DS.Module.Core.Enums.TaskPlat
{
/// <summary>
/// 任务配置类型编码
@ -6,8 +8,9 @@
public enum TaskConfigTypeCodeEnum
{
/// <summary>
/// 不创建任务
/// 不生成任务
/// </summary>
[Description("不生成任务")]
NotCreateTask = 0
}
}

@ -20,6 +20,10 @@
layout="${longdate}|${event-properties:item=EventId_Id}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring}|url: ${aspnet-request-url}|action: ${aspnet-mvc-action} ${newline}" />
<!-- 将日志写入控制台 -->
<target name="console" xsi:type="ColoredConsole" layout="${longdate} ${message} ${exception:format=tostring}" />
<!-- 任务台相关日志 -->
<target xsi:type="File" name="taskflow" fileName="..\TaskLogs\nlog-taskflow-${shortdate}.log"
layout="${longdate}|${event-properties:item=EventId_Id}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring} ${newline}" />
</targets>
<rules>
@ -28,6 +32,9 @@
<!-- <logger name="*" minlevel="Trace" writeTo="allfile" /> -->
<logger name="*" minlevel="Trace" writeTo="console" />
<!-- 将任务台相关日志 -->
<logger name="TaskFlowLogger" writeTo="taskflow" />
<!--跳过非关键的Microsoft日志因此只记录自己的日志-->
<logger name="Microsoft.*" maxlevel="Info" final="true" />
<!-- BlackHole without writeTo -->

@ -20,6 +20,10 @@
layout="${longdate}|${event-properties:item=EventId_Id}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring}|url: ${aspnet-request-url}|action: ${aspnet-mvc-action} ${newline}" />
<!-- 将日志写入控制台 -->
<target name="console" xsi:type="ColoredConsole" layout="${longdate} ${message} ${exception:format=tostring}" />
<!-- 任务台相关日志 -->
<target xsi:type="File" name="taskflow" fileName="..\TaskLogs\nlog-taskflow-${shortdate}.log"
layout="${longdate}|${event-properties:item=EventId_Id}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring} ${newline}" />
</targets>
<rules>
@ -28,6 +32,9 @@
<!-- <logger name="*" minlevel="Trace" writeTo="allfile" /> -->
<logger name="*" minlevel="Trace" writeTo="console" />
<!-- 任务台相关日志 -->
<logger name="TaskFlowLogger" writeTo="taskflow" />
<!--跳过非关键的Microsoft日志因此只记录自己的日志-->
<logger name="Microsoft.*" maxlevel="Info" final="true" />
<!-- BlackHole without writeTo -->

@ -11,6 +11,7 @@
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DocumentationFile>bin\Debug\net8.0\Data.xml</DocumentationFile>
<DocumentationFile>..\DS.WMS.TaskApi\bin\Debug\net8.0\Data.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">

@ -0,0 +1,23 @@
namespace DS.WMS.Core.TaskPlat.Dtos
{
/// <summary>
/// 是否创建任务配置列表查询结果Dto
/// </summary>
public class CreateTaskConfigDto
{
/// <summary>
/// 任务类型编码
/// </summary>
public string TaskTypeCode { get; set; }
/// <summary>
/// 任务类型名称
/// </summary>
public string TaskTypeName { get; set; }
/// <summary>
/// 是否创建
/// </summary>
public bool IsCreate { get; set; }
}
}

@ -12,8 +12,8 @@ namespace DS.WMS.Core.TaskPlat.Entity
/// <summary>
/// 任务类型
/// </summary>
[SugarColumn(ColumnDescription = "所属任务类型", IsNullable = false, Length = 255)]
public required string TaskType { get; set; }
[SugarColumn(ColumnDescription = "所属任务类型", IsNullable = false, Length = 255,DefaultValue ="")]
public string TaskType { get; set; } = "";
///// <summary>
///// 是否创建任务 1=创建
@ -24,19 +24,19 @@ namespace DS.WMS.Core.TaskPlat.Entity
/// <summary>
/// 配置类型编码
/// </summary>
[SugarColumn(ColumnDescription = "配置类型编码", IsNullable = false, Length = 255)]
public required string ConfigTypeCode { get; set; }
[SugarColumn(ColumnDescription = "配置类型编码", IsNullable = false, Length = 255, DefaultValue = "")]
public string ConfigTypeCode { get; set; } = "";
/// <summary>
/// 配置类型名称
/// </summary>
[SugarColumn(ColumnDescription = "配置类型名称", IsNullable = false, Length = 255)]
public required string ConfigTypeName { get; set; }
[SugarColumn(ColumnDescription = "配置类型名称", IsNullable = false, Length = 255, DefaultValue = "")]
public string ConfigTypeName { get; set; } = "";
/// <summary>
/// 配置值
/// </summary>
[SugarColumn(ColumnDescription = "配置值", IsNullable = false, Length = 255)]
public required string ConfigValue { get; set; }
[SugarColumn(ColumnDescription = "配置值", IsNullable = false, Length = 255, DefaultValue = "")]
public string ConfigValue { get; set; } = "";
}
}

@ -70,7 +70,7 @@ namespace DS.WMS.Core.TaskPlat.Interface
/// <param name="userIdList">用户Id列表用于筛选指定用户下的任务[可选,当不为空时会设置此用户列表涉及到的相关任务的状态]</param>
/// <param name="childBsno">子业务主键[可选,当不为空时表示设置子任务的状态]</param>
/// <param name="childTaskBaseTypeEnum">子业务类型</param>
Task<DataResult> SetTaskStatusWithBsno(long bsno, TaskBaseTypeEnum taskBaseTypeEnum, TaskStatusEnum taskStatusEnum, DateTime? statusTime,bool isCheckAllChildTaskComplete, string? taskDesc = null, List<long>? userIdList = null,
Task<DataResult> SetTaskStatusWithBsno(long bsno, TaskBaseTypeEnum taskBaseTypeEnum, TaskStatusEnum taskStatusEnum, DateTime? statusTime, bool isCheckAllChildTaskComplete, string? taskDesc = null, List<long>? userIdList = null,
long? childBsno = null, TaskBaseTypeEnum? childTaskBaseTypeEnum = null);
/// <summary>
/// 工作流任务转交
@ -99,7 +99,7 @@ namespace DS.WMS.Core.TaskPlat.Interface
/// <summary>
/// 测试用
/// </summary>
Task<DataResult> TestTaskFlow(string taskType, long taskId, int testType);
Task<DataResult> TestTaskFlow(string taskType, long taskId, int testType, string content);
/// <summary>
/// 领取任务到当前登陆人(可批量)
@ -110,5 +110,17 @@ namespace DS.WMS.Core.TaskPlat.Interface
/// 任务台台账子任务列表查询
/// </summary>
Task<DataResult<List<dynamic>>> GetChildTaskList(long taskId);
/// <summary>
/// 保存任务是否生成的配置
/// </summary>
/// <param name="taskTypeCode">任务类型编码</param>
/// <param name="isCreate">是否生成任务</param>
Task<DataResult> SaveCreateTaskConfig(string taskTypeCode, bool isCreate);
/// <summary>
/// 获取任务是否生成的配置列表
/// </summary>
Task<DataResult<List<CreateTaskConfigDto>>> GetCreateTaskConfigList();
}
}

@ -38,10 +38,10 @@ namespace DS.WMS.Core.TaskPlat.Method
private readonly ISeaExportCommonService _seaExportCommonService;
private readonly IBookingSlotService _bookingSlotService;
public TaskManageCutDateChangeService(IUser user, ILogger<TaskManageCutDateChangeService> logger,
public TaskManageCutDateChangeService(IUser user,
ISaasDbService saasDbService,
IServiceProvider serviceProvider,
IWebHostEnvironment environment) : base(user, logger, saasDbService, serviceProvider, environment)
IWebHostEnvironment environment) : base(user, saasDbService, serviceProvider, environment)
{
user = serviceProvider.GetRequiredService<IUser>();
_seaExportService = serviceProvider.GetRequiredService<ISeaExportService>();

@ -32,10 +32,10 @@ namespace DS.WMS.Core.TaskPlat.Method
private readonly ITaskMailService _taskMailService;
private readonly ITaskAllocationService _taskAllocationService;
public TaskPOLContainerNotPickUpService(IUser user, ILogger<TaskPOLContainerNotPickUpService> logger,
public TaskPOLContainerNotPickUpService(IUser user,
ISaasDbService saasDbService,
IServiceProvider serviceProvider,
IWebHostEnvironment environment) : base(user, logger, saasDbService, serviceProvider, environment)
IWebHostEnvironment environment) : base(user, saasDbService, serviceProvider, environment)
{
//_serviceProvider = serviceProvider;
//db = serviceProvider.GetRequiredService<ISqlSugarClient>();

@ -95,7 +95,7 @@ namespace DS.WMS.Core.TaskPlat.Method
public TaskManageBCService(IUser user,
ILogger<TaskManageBCService> logger,
//ILogger<TaskManageBCService> logger,
ISaasDbService saasDbService,
IServiceProvider serviceProvider,
IWebHostEnvironment environment,
@ -110,7 +110,7 @@ namespace DS.WMS.Core.TaskPlat.Method
IMappingPortService mappingPortService,
ICodeCountryService codeCountryService,
ICommonService commonService)
: base(user, logger, saasDbService, serviceProvider, environment)
: base(user, saasDbService, serviceProvider, environment)
{
_userService = userService;
_userEmailService = userEmailService;
@ -3100,6 +3100,7 @@ namespace DS.WMS.Core.TaskPlat.Method
{
return DataResult.Failed("未获取到BC任务对象TaskBaseInfo");
}
logger.LogInformation($"BCTaskCompleteThenNext taskBaseInfo.id={taskBaseInfo.Id};taskBaseInfo.OUT_BS_NO={taskBaseInfo.OUT_BS_NO}");
await SetTaskStatus(taskBaseInfo, TaskStatusEnum.Complete, DateTime.Now, false);

@ -37,7 +37,8 @@ namespace DS.WMS.Core.TaskPlat.Method
{
// 实例化时构建
protected readonly IUser user;
protected readonly ILogger<T> logger;
//protected readonly ILogger<T> logger;
protected readonly ILogger logger;
protected readonly ISaasDbService saasDbService;
protected readonly IServiceProvider serviceProvider;
protected readonly IWebHostEnvironment environment;
@ -53,13 +54,13 @@ namespace DS.WMS.Core.TaskPlat.Method
protected static readonly string completeStatusStr = TaskStatusEnum.Complete.ToString();
public TaskManageBaseService(IUser user,
ILogger<T> logger,
//ILogger<T> logger,
ISaasDbService saasDbService,
IServiceProvider serviceProvider,
IWebHostEnvironment environment)
{
this.user = user;
this.logger = logger;
//this.logger = logger;
this.saasDbService = saasDbService;
this.serviceProvider = serviceProvider;
this.environment = environment;
@ -69,6 +70,9 @@ namespace DS.WMS.Core.TaskPlat.Method
allocationService = new Lazy<ITaskAllocationService>(serviceProvider.GetRequiredService<ITaskAllocationService>());
seaExportCommonService = new Lazy<ISeaExportCommonService>(serviceProvider.GetRequiredService<ISeaExportCommonService>());
djyServiceStatusService = new Lazy<IDjyServiceStatusService>(serviceProvider.GetRequiredService<IDjyServiceStatusService>());
var loggerFactory = serviceProvider.GetRequiredService<ILoggerFactory>();
logger = loggerFactory.CreateLogger("TaskFlowLogger");
}
/// <summary>
@ -78,6 +82,8 @@ namespace DS.WMS.Core.TaskPlat.Method
/// <param name="columns">需要更新状态的列</param>
public async Task SetTaskStatus(long[] taskIds, params Expression<Func<TaskBaseInfo, bool>>[] columns)
{
logger.LogInformation($"SetTaskStatus taskIds={string.Join(",", taskIds ?? [])}");
SqlSugarScopeProvider tenantDb = saasDbService.GetBizDbScopeById(user.TenantId);
//任务不考虑OrgId,这里去掉
tenantDb.QueryFilter.Clear<IOrgId>();
@ -104,6 +110,8 @@ namespace DS.WMS.Core.TaskPlat.Method
/// <param name="userInfo">人员信息列表</param>
public async Task SetTaskOwner(long[] taskIds, List<RecvUserInfo> userInfo)
{
logger.LogInformation($"SetTaskOwner taskIds={string.Join(",", taskIds ?? [])};userInfo={JsonConvert.SerializeObject(userInfo)}");
SqlSugarScopeProvider tenantDb = saasDbService.GetBizDbScopeById(user.TenantId);
//任务不考虑OrgId,这里去掉
tenantDb.QueryFilter.Clear<IOrgId>();
@ -582,6 +590,7 @@ namespace DS.WMS.Core.TaskPlat.Method
/// <param name="bsno">业务主键</param>
public async Task<DataResult> SetTaskStatus(long taskBaseId, TaskStatusEnum taskStatusEnum, DateTime? statusTime, long? bsno = null)
{
logger.LogInformation($"SetTaskStatus taskBaseId={taskBaseId};taskStatusEnum={taskStatusEnum};statusTime={statusTime};bsno={bsno}");
SqlSugarScopeProvider tenantDb = saasDbService.GetBizDbScopeById(user.TenantId);
TaskBaseInfo taskInfo = await tenantDb.Queryable<TaskBaseInfo>().ClearFilter(typeof(IOrgId))
@ -606,6 +615,7 @@ namespace DS.WMS.Core.TaskPlat.Method
{
throw new ArgumentNullException(nameof(taskInfo));
}
logger.LogInformation($"SetTaskStatus 通用 taskInfo={JsonConvert.SerializeObject(taskInfo)};taskStatusEnum={taskStatusEnum};statusTime={statusTime};isCheckAllChildTaskComplete={isCheckAllChildTaskComplete};bsno={bsno};taskDesc={taskDesc}");
SqlSugarScopeProvider tenantDb = saasDbService.GetBizDbScopeById(user.TenantId);

@ -3,6 +3,7 @@ using DS.Module.Core.Condition;
using DS.Module.Core.Constants;
using DS.Module.Core.Data;
using DS.Module.Core.Enums;
using DS.Module.Core.Enums.TaskPlat;
using DS.Module.Core.Extensions;
using DS.Module.Core.Helpers;
using DS.Module.DjyServiceStatus;
@ -62,7 +63,7 @@ namespace DS.WMS.Core.TaskPlat.Method
static string[] seaExportFields = ["customerid", "saleid", "customerservice", "operatorid"]; //, "portload_code", "portdischarge_code"
public TaskManageService(IUser user,
ILogger<TaskManageService> logger,
//ILogger<TaskManageService> logger,
ISaasDbService saasDbService,
IServiceProvider serviceProvider,
IWebHostEnvironment environment,
@ -71,7 +72,7 @@ namespace DS.WMS.Core.TaskPlat.Method
IMappingPortService mappingPortService,
IMappingCarrierService mappingCarrierService,
ICodeCarrierService codeCarrierService,
ICommonService commonService) : base(user, logger, saasDbService, serviceProvider, environment)
ICommonService commonService) : base(user, saasDbService, serviceProvider, environment)
{
this.codeCtnService = codeCtnService;
this.codePortService = codePortService;
@ -97,7 +98,7 @@ namespace DS.WMS.Core.TaskPlat.Method
public async Task<DataResult> SetTaskUserStatus(long bsno, TaskBaseTypeEnum taskBaseTypeEnum, TaskStatusEnum taskStatusEnum, DateTime? statusTime, List<RecvUserInfo> userInfos,
long? childBsno = null, TaskBaseTypeEnum? childTaskBaseTypeEnum = null)
{
logger.LogInformation("接收到任务个人状态修改报文 bsno={bsno} 状态设置={status} 人员列表={userList} childBsno={childBsno} childTaskBaseTypeEnum={childTaskBaseTypeEnum}", bsno, taskStatusEnum.ToString(), JsonConvert.SerializeObject(userInfos), childBsno, childTaskBaseTypeEnum);
logger.LogInformation($"{nameof(SetTaskStatusWithBsno)} bsno={bsno};taskBaseTypeEnum={taskBaseTypeEnum};taskStatusEnum={taskStatusEnum};statusTime={statusTime};userInfos={(userInfos == null ? "" : string.Join(',', userInfos ?? []))};childBsno={childBsno};childTaskBaseTypeEnum={childTaskBaseTypeEnum}");
SqlSugarScopeProvider tenantDb = saasDbService.GetBizDbScopeById(user.TenantId);
@ -177,6 +178,8 @@ namespace DS.WMS.Core.TaskPlat.Method
public async Task<DataResult> SetTaskStatusWithBsno(long bsno, TaskBaseTypeEnum taskBaseTypeEnum, TaskStatusEnum taskStatusEnum, DateTime? statusTime, bool isCheckAllChildTaskComplete, string? taskDesc = null, List<long>? userIdList = null,
long? childBsno = null, TaskBaseTypeEnum? childTaskBaseTypeEnum = null)
{
logger.LogInformation($"SetTaskStatusWithBsno bsno={bsno};taskBaseTypeEnum={taskBaseTypeEnum};taskStatusEnum={taskStatusEnum};statusTime={statusTime};isCheckAllChildTaskComplete={isCheckAllChildTaskComplete};taskDesc={taskDesc};userIdList={(userIdList == null ? "" : string.Join(',', userIdList))};childBsno={childBsno};childTaskBaseTypeEnum={childTaskBaseTypeEnum}");
SqlSugarScopeProvider tenantDb = saasDbService.GetBizDbScopeById(user.TenantId);
var taskTypeStr = taskBaseTypeEnum.ToString();
@ -281,6 +284,8 @@ namespace DS.WMS.Core.TaskPlat.Method
public async Task<DataResult> TransferTask(long bsno, TaskBaseTypeEnum taskBaseTypeEnum, List<RecvUserInfo> userInfos, SqlSugarScopeProvider? tenantDb = null,
long? childBsno = null, TaskBaseTypeEnum? childTaskBaseTypeEnum = null)
{
logger.LogInformation($"TransferTask bsno={bsno};taskBaseTypeEnum={taskBaseTypeEnum};userInfos={(userInfos == null ? "" : string.Join(',', userInfos))};childBsno={childBsno};childTaskBaseTypeEnum={childTaskBaseTypeEnum}");
tenantDb ??= saasDbService.GetBizDbScopeById(user.TenantId);
logger.LogInformation("接收到任务转交报文 bsno={bsno} taskBaseTypeEnum={taskBaseTypeEnum} 转交人员列表={userinfo} childBsno={childBsno} childTaskBaseTypeEnum={childTaskBaseTypeEnum}",
@ -394,6 +399,7 @@ namespace DS.WMS.Core.TaskPlat.Method
long? childBsno = null, TaskBaseTypeEnum? childTaskBaseTypeEnum = null,
params Expression<Func<TaskBaseInfo, bool>>[] columns)
{
logger.LogInformation($"SetTaskBaseInfoPropertyWithBsno bsno={bsno};taskBaseTypeEnum={taskBaseTypeEnum};childBsno={childBsno};childTaskBaseTypeEnum={childTaskBaseTypeEnum};");
SqlSugarScopeProvider tenantDb = saasDbService.GetBizDbScopeById(user.TenantId);
@ -463,10 +469,10 @@ namespace DS.WMS.Core.TaskPlat.Method
public async Task<DataResult> InitTaskJob(TaskManageOrderMessageInfo info, IFormFile file = null, IFormFile modifyFile = null)
{
string batchNo = Guid.NewGuid().ToString();
logger.LogInformation($"{nameof(InitTaskJob)} bsno={info?.Head.BSNO}; ChildBSNO={info?.Head?.ChildBSNO};info={JsonConvert.SerializeObject(info)}");
try
{
//Monitor.Enter(ImportLockObj);
logger.LogInformation("批次={no} 接收到创建任务报文 报文={msg}", batchNo, JsonConvert.SerializeObject(info));
if (info.Head.IsChild && info.Head.ChildBSNO == 0)
{
@ -3858,6 +3864,7 @@ namespace DS.WMS.Core.TaskPlat.Method
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
result.bno = model.TASK_NO;
logger.LogInformation($"InnerManualTask batchNo={batchNo};model.OUT_BS_NO={model.OUT_BS_NO};model.Id={model.Id};taskOperTypeEnum={taskOperTypeEnum};");
try
{
@ -4164,6 +4171,9 @@ namespace DS.WMS.Core.TaskPlat.Method
});
var taskIdList = taskList.Select(x => x.Id).ToList();
logger.LogInformation($"PullTask taskIdList={string.Join(",", taskIdList)}");
var taskTypeList = taskList.Where(x => x.TASK_SOURCE == TaskSourceEnum.WORK_FLOW.ToString() && x.OUT_BS_NO != null).Select(x => x.TASK_TYPE).Distinct().ToList();
var taskCompleteStatusCodeList = taskTypeList.Count > 0 ? await tenantDb.Queryable<TaskFlowModule>()
@ -4231,6 +4241,7 @@ namespace DS.WMS.Core.TaskPlat.Method
catch (Exception ex)
{
await tenantDb.AsTenant().RollbackTranAsync();
logger.LogError($"PullTask Exception 原因:{ex.Message}");
return DataResult.Failed("任务领取失败,原因:" + ex.Message);
}
}
@ -4239,9 +4250,8 @@ namespace DS.WMS.Core.TaskPlat.Method
/// <summary>
/// 测试用
/// </summary>
public async Task<DataResult> TestTaskFlow(string taskType, long taskId, int testType)
public async Task<DataResult> TestTaskFlow(string taskType, long taskId, int testType, string? content = null)
{
var tenantDb = saasDbService.GetBizDbScopeById(user.TenantId);
@ -4409,10 +4419,100 @@ namespace DS.WMS.Core.TaskPlat.Method
var temp2 = tenantDb.Ado.SqlQuery<dynamic>("select * from task_flow_module where id in(@id)", p);
break;
}
case 8:
{
//await serviceProvider.GetRequiredService<taskmana>
var taskTypeEnum = (TaskBaseTypeEnum)Enum.Parse(typeof(TaskBaseTypeEnum), taskType);
await SetTaskBaseInfoPropertyWithBsno(taskId, taskTypeEnum, null, null, x => x.TASK_DESP == content);
break;
}
}
return DataResult.Successed("测试成功");
}
#region 任务台配置维护相关
/// <summary>
/// 获取任务是否生成配置列表
/// </summary>
public async Task<DataResult<List<CreateTaskConfigDto>>> GetCreateTaskConfigList()
{
var type = typeof(TaskBaseTypeEnum);
List<TaskBaseTypeEnum> allServiceItemTask = Enum.GetValues(type)
.Cast<TaskBaseTypeEnum>()
.Where(x => Convert.ToInt32(x) >= 300 && Convert.ToInt32(x) < 400)
.ToList();
var tenantDb = saasDbService.GetBizDbScopeById(user.TenantId);
var noCreateTaskType = await GetNotCreateTaskTypeList(tenantDb);
var result = allServiceItemTask.Select(x => new CreateTaskConfigDto()
{
TaskTypeCode = x.ToString(),
TaskTypeName = x.EnumDescription(),
IsCreate = !noCreateTaskType.Contains(x)
}).ToList();
return DataResult<List<CreateTaskConfigDto>>.Success(result);
}
/// <summary>
/// 保存任务是否生成的配置
/// </summary>
/// <param name="taskTypeCode">任务类型编码</param>
/// <param name="isCreate">是否生成任务</param>
public async Task<DataResult> SaveCreateTaskConfig(string taskTypeCode, bool isCreate)
{
var tenantDb = saasDbService.GetBizDbScopeById(user.TenantId);
if (!Enum.TryParse(typeof(TaskBaseTypeEnum), taskTypeCode, out _))
{
return DataResult.FailedWithDesc(MultiLanguageConst.TaskTypeError);
}
var configTypeStr = TaskConfigTypeCodeEnum.NotCreateTask.ToString();
var notCreateTaskConfigList = await tenantDb.Queryable<TaskFlowTypeConfig>()
.Where(x => x.ConfigTypeCode == configTypeStr && x.TaskType == taskTypeCode)
//.Select(x => x.Id)
.ToListAsync();
try
{
await tenantDb.Ado.BeginTranAsync();
if (notCreateTaskConfigList.Count > 1)
{
var ids = notCreateTaskConfigList.Select(x => x.Id);
await tenantDb.Deleteable<TaskFlowTypeConfig>().Where(x => ids.Contains(x.Id)).ExecuteCommandAsync();
}
if (notCreateTaskConfigList.Count > 1 || notCreateTaskConfigList.Count == 0)
{
var model = new TaskFlowTypeConfig()
{
ConfigTypeCode = configTypeStr,
ConfigTypeName = TaskConfigTypeCodeEnum.NotCreateTask.EnumDescription(),
ConfigValue = isCreate ? "0" : "1",
TaskType = taskTypeCode
};
await tenantDb.Insertable(model).ExecuteCommandAsync();
}
else
{
var updateModel = notCreateTaskConfigList.First();
updateModel.ConfigValue = isCreate ? "0" : "1";
await tenantDb.Updateable(updateModel).ExecuteCommandAsync();
}
await tenantDb.Ado.CommitTranAsync();
return DataResult.Success;
}
catch (Exception)
{
await tenantDb.Ado.RollbackTranAsync();
throw;
}
}
#endregion
}
/// <summary>

@ -20,6 +20,10 @@
layout="${longdate}|${event-properties:item=EventId_Id}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring}|url: ${aspnet-request-url}|action: ${aspnet-mvc-action} ${newline}" />
<!-- 将日志写入控制台 -->
<target name="console" xsi:type="ColoredConsole" layout="${longdate} ${message} ${exception:format=tostring}" />
<!-- 任务台相关日志 -->
<target xsi:type="File" name="taskflow" fileName="..\TaskLogs\nlog-taskflow-${shortdate}.log"
layout="${longdate}|${event-properties:item=EventId_Id}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring} ${newline}" />
</targets>
<rules>
@ -28,6 +32,9 @@
<!-- <logger name="*" minlevel="Trace" writeTo="allfile" /> -->
<logger name="*" minlevel="Trace" writeTo="console" />
<!-- 任务台相关日志 -->
<logger name="TaskFlowLogger" writeTo="taskflow" />
<!--跳过非关键的Microsoft日志因此只记录自己的日志-->
<logger name="Microsoft.*" maxlevel="Info" final="true" />
<!-- BlackHole without writeTo -->

@ -20,6 +20,10 @@
layout="${longdate}|${event-properties:item=EventId_Id}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring}|url: ${aspnet-request-url}|action: ${aspnet-mvc-action} ${newline}" />
<!-- 将日志写入控制台 -->
<target name="console" xsi:type="ColoredConsole" layout="${longdate} ${message} ${exception:format=tostring}" />
<!-- 任务台相关日志 -->
<target xsi:type="File" name="taskflow" fileName="..\TaskLogs\nlog-taskflow-${shortdate}.log"
layout="${longdate}|${event-properties:item=EventId_Id}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring} ${newline}" />
</targets>
<rules>
@ -27,6 +31,9 @@
<!--minlevel 改为Trace 跟踪全部 Error 只捕获异常-->
<!-- <logger name="*" minlevel="Trace" writeTo="allfile" /> -->
<logger name="*" minlevel="Trace" writeTo="console" />
<!-- 将任务台相关日志 -->
<logger name="TaskFlowLogger" writeTo="taskflow" />
<!--跳过非关键的Microsoft日志因此只记录自己的日志-->
<logger name="Microsoft.*" maxlevel="Info" final="true" />

@ -20,6 +20,10 @@
layout="${longdate}|${event-properties:item=EventId_Id}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring}|url: ${aspnet-request-url}|action: ${aspnet-mvc-action} ${newline}" />
<!-- 将日志写入控制台 -->
<target name="console" xsi:type="ColoredConsole" layout="${longdate} ${message} ${exception:format=tostring}" />
<!-- 任务台相关日志 -->
<target xsi:type="File" name="taskflow" fileName="..\TaskLogs\nlog-taskflow-${shortdate}.log"
layout="${longdate}|${event-properties:item=EventId_Id}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring} ${newline}" />
</targets>
<rules>
@ -28,9 +32,12 @@
<!-- <logger name="*" minlevel="Trace" writeTo="allfile" /> -->
<logger name="*" minlevel="Trace" writeTo="console" />
<!--跳过非关键的Microsoft日志因此只记录自己的日志-->
<logger name="Microsoft.*" maxlevel="Info" final="true" />
<!-- BlackHole without writeTo -->
<!-- 任务台相关日志 -->
<logger name="TaskFlowLogger" writeTo="taskflow" />
<!--跳过非关键的Microsoft日志因此只记录自己的日志-->
<logger name="Microsoft.*" maxlevel="Info" final="true" />
<!-- BlackHole without writeTo -->
<logger name="*" minlevel="Trace" writeTo="ownFile-web" />
</rules>
</nlog>

@ -20,6 +20,10 @@
layout="${longdate}|${event-properties:item=EventId_Id}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring}|url: ${aspnet-request-url}|action: ${aspnet-mvc-action} ${newline}" />
<!-- 将日志写入控制台 -->
<target name="console" xsi:type="ColoredConsole" layout="${longdate} ${message} ${exception:format=tostring}" />
<!-- 任务台相关日志 -->
<target xsi:type="File" name="taskflow" fileName="..\TaskLogs\nlog-taskflow-${shortdate}.log"
layout="${longdate}|${event-properties:item=EventId_Id}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring} ${newline}" />
</targets>
<rules>
@ -28,7 +32,10 @@
<!-- <logger name="*" minlevel="Trace" writeTo="allfile" /> -->
<logger name="*" minlevel="Trace" writeTo="console" />
<!--跳过非关键的Microsoft日志因此只记录自己的日志-->
<!-- 任务台相关日志 -->
<logger name="TaskFlowLogger" writeTo="taskflow" />
<!--跳过非关键的Microsoft日志因此只记录自己的日志-->
<logger name="Microsoft.*" maxlevel="Info" final="true" />
<!-- BlackHole without writeTo -->
<logger name="*" minlevel="Trace" writeTo="ownFile-web" />

@ -233,9 +233,9 @@ public class TaskManageController : ApiController
/// 测试用
/// </summary>
[HttpGet("TestTaskFlow")]
public async Task<DataResult> TestTaskFlow([FromQuery] string taskType, [FromQuery] long taskId, [FromQuery] int testType)
public async Task<DataResult> TestTaskFlow([FromQuery] string taskType, [FromQuery] long taskId, [FromQuery] int testType, [FromQuery] string content)
{
return await taskManageService.TestTaskFlow(taskType, taskId, testType);
return await taskManageService.TestTaskFlow(taskType, taskId, testType, content);
}
/// <summary>
@ -246,4 +246,24 @@ public class TaskManageController : ApiController
{
return await taskManageService.PullTask(Ids);
}
/// <summary>
/// 获取任务是否生成配置列表
/// </summary>
[HttpGet("GetCreateTaskConfigList")]
public async Task<DataResult<List<CreateTaskConfigDto>>> GetCreateTaskConfigList()
{
return await taskManageService.GetCreateTaskConfigList();
}
/// <summary>
/// 保存任务是否生成的配置
/// </summary>
/// <param name="taskTypeCode">任务类型编码</param>
/// <param name="isCreate">是否生成任务</param>
[HttpPost("SaveCreateTaskConfig")]
public async Task<DataResult> SaveCreateTaskConfig([FromForm] string taskTypeCode, [FromForm] bool isCreate)
{
return await taskManageService.SaveCreateTaskConfig(taskTypeCode, isCreate);
}
}

@ -4,33 +4,40 @@
autoReload="true"
internalLogLevel="info"
internalLogFile="Logs\internal-nlog.txt">
<!-- enable asp.net core layout renderers -->
<extensions>
<add assembly="NLog.Web.AspNetCore" />
</extensions>
<!-- enable asp.net core layout renderers -->
<extensions>
<add assembly="NLog.Web.AspNetCore" />
</extensions>
<targets>
<!-- 写入文件配置 -->
<!-- 将日志写入文件 -->
<target xsi:type="File" name="allfile" fileName="Logs\nlog-all-${shortdate}.log"
<targets>
<!-- 写入文件配置 -->
<!-- 将日志写入文件 -->
<target xsi:type="File" name="allfile" fileName="Logs\nlog-all-${shortdate}.log"
layout="${longdate}|${event-properties:item=EventId_Id}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring} ${newline}" />
<!-- 另一个文件日志只有自己的日志。使用一些ASP.NET核心渲染器 -->
<target xsi:type="File" name="ownFile-web" fileName="Logs\nlog-own-${shortdate}.log"
<!-- 另一个文件日志只有自己的日志。使用一些ASP.NET核心渲染器 -->
<target xsi:type="File" name="ownFile-web" fileName="Logs\nlog-own-${shortdate}.log"
layout="${longdate}|${event-properties:item=EventId_Id}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring}|url: ${aspnet-request-url}|action: ${aspnet-mvc-action} ${newline}" />
<!-- 将日志写入控制台 -->
<target name="console" xsi:type="ColoredConsole" layout="${longdate} ${message} ${exception:format=tostring}" />
</targets>
<!-- 将日志写入控制台 -->
<target name="console" xsi:type="ColoredConsole" layout="${longdate} ${message} ${exception:format=tostring}" />
<rules>
<!--所有日志包括来自Microsoft的-->
<!--minlevel 改为Trace 跟踪全部 Error 只捕获异常-->
<!-- <logger name="*" minlevel="Trace" writeTo="allfile" /> -->
<logger name="*" minlevel="Trace" writeTo="console" />
<!-- 任务台相关日志 -->
<target xsi:type="File" name="taskflow" fileName="..\TaskLogs\nlog-taskflow-${shortdate}.log"
layout="${longdate}|${event-properties:item=EventId_Id}|${uppercase:${level}}|${logger}|${message} ${exception:format=tostring} ${newline}" />
</targets>
<rules>
<!--所有日志包括来自Microsoft的-->
<!--minlevel 改为Trace 跟踪全部 Error 只捕获异常-->
<!-- <logger name="*" minlevel="Trace" writeTo="allfile" /> -->
<logger name="*" minlevel="Trace" writeTo="console" />
<!-- 任务台相关日志 -->
<logger name="TaskFlowLogger" writeTo="taskflow" />
<!--跳过非关键的Microsoft日志因此只记录自己的日志-->
<logger name="Microsoft.*" maxlevel="Info" final="true" />
<!-- BlackHole without writeTo -->
<logger name="*" minlevel="Trace" writeTo="ownFile-web" />
</rules>
<!--跳过非关键的Microsoft日志因此只记录自己的日志-->
<logger name="Microsoft.*" maxlevel="Info" final="true" />
<!-- BlackHole without writeTo -->
<logger name="*" minlevel="Trace" writeTo="ownFile-web" />
</rules>
</nlog>
Loading…
Cancel
Save