wet 1 year ago
commit 07497e4da1

@ -0,0 +1,46 @@
using Myshipping.Core;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Myshipping.Application
{
/// <summary>
/// 触发器条件触发其他流程活动
/// </summary>
[SugarTable("status_trigger_condition_next_act")]
[Description("触发器条件触发其他流程活动")]
[Tenant(CommonConst.MasterDb)]
public class StatusTriggerConditionNextActInfo
{
/// <summary>
/// 主键
/// </summary>
[SugarColumn(ColumnDescription = "主键", IsPrimaryKey = true)]
public string PK_ID { get; set; }
/// <summary>
/// 触发器主键
/// </summary>
public string TRIGGER_ID { get; set; }
/// <summary>
/// 条件ID
/// </summary>
public string CONDITION_ID { get; set; }
/// <summary>
/// 服务活动主键
/// </summary>
public string SERVICE_ACTIVITIES_ID { get; set; }
/// <summary>
/// 状态显示名称
/// </summary>
public string SHOW_NAME { get; set; }
}
}

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Myshipping.Application
{
/// <summary>
/// 触发器触发动作枚举
/// </summary>
public enum StatusTriggerNextActionTypeEnum
{
/// <summary>
/// 消息提醒
/// </summary>
[Description("消息提醒")]
MESSAGE_CAUTION,
/// <summary>
/// 触发其他状态
/// </summary>
[Description("触发其他状态#SHOWACTS#")]
TRIGGER_ACTIVITIES
}
}

@ -15,47 +15,52 @@ namespace Myshipping.Application
/// <summary> /// <summary>
/// 第N天后 /// 第N天后
/// </summary> /// </summary>
[Description("第N天后#DAYS#")] [Description("第N天后#DAYS#,func_DelayExcuteRun")]
DATE_NEXT_DAY, DATE_NEXT_DAY,
/// <summary> /// <summary>
/// 已完成
/// </summary>
[Description("已完成,func_DelayExcuteRun")]
IS_YIELD,
/// <summary>
/// 等于 /// 等于
/// </summary> /// </summary>
[Description("等于")] [Description("等于,==")]
EQUALS, EQUALS,
/// <summary> /// <summary>
/// 不等于 /// 不等于
/// </summary> /// </summary>
[Description("不等于")] [Description("不等于,!=")]
DOES_NOT_EQUAL, DOES_NOT_EQUAL,
/// <summary> /// <summary>
/// 大于 /// 大于
/// </summary> /// </summary>
[Description("大于")] [Description("大于,>")]
GREATER_THAN, GREATER_THAN,
/// <summary> /// <summary>
/// 大于等于 /// 大于等于
/// </summary> /// </summary>
[Description("大于等于")] [Description("大于等于,>=")]
GREATER_THEN_EQUAL, GREATER_THEN_EQUAL,
/// <summary> /// <summary>
/// 小于 /// 小于
/// </summary> /// </summary>
[Description("小于")] [Description("小于,<")]
LESS_THAN, LESS_THAN,
/// <summary> /// <summary>
/// 小于等于 /// 小于等于
/// </summary> /// </summary>
[Description("小于等于")] [Description("小于等于,<=")]
LESS_THAN_EQUAL, LESS_THAN_EQUAL,
/// <summary> /// <summary>
/// 或者 /// 或者
/// </summary> /// </summary>
[Description("或者")] [Description("或者,&&")]
LOGICAL_OR, LOGICAL_OR,
/// <summary> /// <summary>
/// 并且 /// 并且
/// </summary> /// </summary>
[Description("并且")] [Description("并且,||")]
LOGICAL_AND LOGICAL_AND

@ -38,6 +38,7 @@
<PackageReference Include="NPOI" Version="2.6.0" /> <PackageReference Include="NPOI" Version="2.6.0" />
<PackageReference Include="Npoi.Mapper" Version="4.1.0" /> <PackageReference Include="Npoi.Mapper" Version="4.1.0" />
<PackageReference Include="RabbitMQ.Client" Version="6.5.0" /> <PackageReference Include="RabbitMQ.Client" Version="6.5.0" />
<PackageReference Include="Scriban" Version="5.7.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

@ -46,6 +46,11 @@ namespace Myshipping.Application
/// </summary> /// </summary>
public List<ServiceWorkFlowActivitiesSubDto> SubList { get; set; } public List<ServiceWorkFlowActivitiesSubDto> SubList { get; set; }
/// <summary>
/// 触发器列表
/// </summary>
public List<StatusTriggerBaseDto> StatusTriggerList { get; set; }
} }
/// <summary> /// <summary>

@ -56,5 +56,9 @@ namespace Myshipping.Application
/// </summary> /// </summary>
public string LiquidExpression { get; set; } public string LiquidExpression { get; set; }
/// <summary>
/// 触发其他流程活动列表
/// </summary>
public List<StatusTriggerConditionNextActDto> NextActList { get; set; }
} }
} }

@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Myshipping.Application
{
/// <summary>
///
/// </summary>
public class StatusTriggerConditionNextActDto
{
/// <summary>
/// 主键
/// </summary>
public string PKId { get; set; }
/// <summary>
/// 触发器主键
/// </summary>
public string TriggerId { get; set; }
/// <summary>
/// 条件ID
/// </summary>
public string ConditionId { get; set; }
/// <summary>
/// 服务活动主键
/// </summary>
public string ServiceActivitiesID { get; set; }
/// <summary>
/// 状态显示名称
/// </summary>
public string ShowName { get; set; }
}
}

@ -185,7 +185,8 @@ namespace Myshipping.Application
config.ForType<StatusTriggerBaseDto, StatusTriggerBaseInfo>() config.ForType<StatusTriggerBaseDto, StatusTriggerBaseInfo>()
.Map(dest => dest.PK_ID, src => src.PKId) .Map(dest => dest.PK_ID, src => src.PKId)
.Map(dest => dest.STATUS_TRIGGER_CODE, src => src.StatusTriggerCode) .Map(dest => dest.STATUS_TRIGGER_CODE, src => src.StatusTriggerCode)
.Map(dest => dest.STATUS_TRIGGER_NAME, src => src.StatusTriggerName); .Map(dest => dest.STATUS_TRIGGER_NAME, src => src.StatusTriggerName)
.Map(dest => dest.STATUS_TRIGGER_NOTE, src => src.StatusTriggerNote);
config.ForType<StatusTriggerBaseInfo, StatusTriggerBaseDto>() config.ForType<StatusTriggerBaseInfo, StatusTriggerBaseDto>()
.Map(dest => dest.PKId, src => src.PK_ID) .Map(dest => dest.PKId, src => src.PK_ID)
@ -257,6 +258,21 @@ namespace Myshipping.Application
.Map(dest => dest.UpdatedUserId, src => src.UpdatedUserId) .Map(dest => dest.UpdatedUserId, src => src.UpdatedUserId)
.Map(dest => dest.UpdatedUserName, src => src.UpdatedUserName); .Map(dest => dest.UpdatedUserName, src => src.UpdatedUserName);
config.ForType<StatusTriggerConditionNextActInfo, StatusTriggerConditionNextActDto>()
.Map(dest => dest.PKId, src => src.PK_ID)
.Map(dest => dest.TriggerId, src => src.TRIGGER_ID)
.Map(dest => dest.ConditionId, src => src.CONDITION_ID)
.Map(dest => dest.ServiceActivitiesID, src => src.SERVICE_ACTIVITIES_ID)
.Map(dest => dest.ShowName, src => src.SHOW_NAME);
config.ForType<StatusTriggerConditionNextActDto,StatusTriggerConditionNextActInfo>()
.Map(dest => dest.PK_ID ,src => src.PKId)
.Map(dest => dest.TRIGGER_ID, src => src.TriggerId)
.Map(dest => dest.CONDITION_ID, src => src.ConditionId)
.Map(dest => dest.SERVICE_ACTIVITIES_ID, src => src.ServiceActivitiesID)
.Map(dest => dest.SHOW_NAME, src => src.ShowName);
} }
} }
} }

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Myshipping.Application
{
public class TriggerNextActionTypeDto
{
/// <summary>
/// 代码
/// </summary>
public string Code { get; set; }
/// <summary>
/// 名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 是否显示流程活动
/// </summary>
public bool IsShowActivities { get; set; }
}
}

@ -75,11 +75,25 @@ namespace Myshipping.Application
/// <returns>返回回执</returns> /// <returns>返回回执</returns>
Task<TaskManageOrderResultDto> GetTriggerOperTypeList(); Task<TaskManageOrderResultDto> GetTriggerOperTypeList();
/// <summary>
/// 获取状态触发器触发动作列表
/// </summary>
/// <returns>返回回执</returns>
Task<TaskManageOrderResultDto> GetTriggerNextActionTypeList();
/// <summary> /// <summary>
/// 生成LIQUID表达式 /// 生成LIQUID表达式
/// </summary> /// </summary>
/// <param name="info">状态触发器条件详情</param> /// <param name="info">状态触发器条件详情</param>
/// <returns>返回回执</returns> /// <returns>返回回执</returns>
Task<TaskManageOrderResultDto> CreateLiquidExpression(StatusTriggerConditionDto info); Task<TaskManageOrderResultDto> CreateLiquidExpression(StatusTriggerConditionDto info);
/// <summary>
/// 测试LIQUID表达式
/// </summary>
/// <param name="info">状态触发器条件详情</param>
/// <param name="liquidExpress">LIQUID表达式</param>
/// <returns>返回回执</returns>
Task<TaskManageOrderResultDto> TestLiquidExpression(StatusTriggerConditionDto info, string liquidExpress);
} }
} }

@ -26,16 +26,18 @@ namespace Myshipping.Application
{ {
private readonly SqlSugarRepository<StatusTriggerBaseInfo> _statusTriggerBaseInfoRepository; private readonly SqlSugarRepository<StatusTriggerBaseInfo> _statusTriggerBaseInfoRepository;
private readonly SqlSugarRepository<StatusTriggerConditionInfo> _statusTriggerConditionInfoRepository; private readonly SqlSugarRepository<StatusTriggerConditionInfo> _statusTriggerConditionInfoRepository;
private readonly SqlSugarRepository<StatusTriggerConditionNextActInfo> _statusTriggerConditionNextActInfoRepository;
private readonly ILogger<StatusTriggerBaseService> _logger; private readonly ILogger<StatusTriggerBaseService> _logger;
public StatusTriggerBaseService(SqlSugarRepository<StatusTriggerBaseInfo> statusTriggerBaseInfoRepository, public StatusTriggerBaseService(SqlSugarRepository<StatusTriggerBaseInfo> statusTriggerBaseInfoRepository,
SqlSugarRepository<StatusTriggerConditionInfo> statusTriggerConditionInfoRepository, SqlSugarRepository<StatusTriggerConditionInfo> statusTriggerConditionInfoRepository,
SqlSugarRepository<StatusTriggerConditionNextActInfo> statusTriggerConditionNextActInfoRepository,
ILogger<StatusTriggerBaseService> logger) ILogger<StatusTriggerBaseService> logger)
{ {
_statusTriggerBaseInfoRepository = statusTriggerBaseInfoRepository; _statusTriggerBaseInfoRepository = statusTriggerBaseInfoRepository;
_statusTriggerConditionInfoRepository = statusTriggerConditionInfoRepository; _statusTriggerConditionInfoRepository = statusTriggerConditionInfoRepository;
_statusTriggerConditionNextActInfoRepository = statusTriggerConditionNextActInfoRepository;
_logger = logger; _logger = logger;
} }
@ -126,7 +128,34 @@ namespace Myshipping.Application
info.ConditionList.ForEach(async cd => { info.ConditionList.ForEach(async cd => {
var conditionModel = cd.Adapt<StatusTriggerConditionInfo>(); var conditionModel = cd.Adapt<StatusTriggerConditionInfo>();
conditionModel.PK_ID = IDGen.NextID().ToString();
conditionModel.P_ID = entity.PK_ID;
conditionModel.CreatedTime = DateTime.Now;
conditionModel.CreatedUserId = UserManager.UserId;
conditionModel.CreatedUserName = UserManager.Name;
conditionModel.IsDeleted = false;
await _statusTriggerConditionInfoRepository.InsertAsync(conditionModel); await _statusTriggerConditionInfoRepository.InsertAsync(conditionModel);
if(cd.NextActionType == StatusTriggerNextActionTypeEnum.TRIGGER_ACTIVITIES.ToString())
{
if(cd.NextActList != null && cd.NextActList.Count > 0)
{
//写入需要触发的其他流程活动
cd.NextActList.ForEach(async nxt => {
var nextModel = new StatusTriggerConditionNextActInfo {
PK_ID = IDGen.NextID().ToString(),
CONDITION_ID = conditionModel.PK_ID,
TRIGGER_ID = entity.PK_ID,
SERVICE_ACTIVITIES_ID = nxt.ServiceActivitiesID,
SHOW_NAME = nxt.ShowName,
};
await _statusTriggerConditionNextActInfoRepository.InsertAsync(nextModel);
});
}
}
}); });
} }
} }
@ -152,16 +181,47 @@ namespace Myshipping.Application
it.IsDeleted, it.IsDeleted,
}).ExecuteCommandAsync(); }).ExecuteCommandAsync();
if (info.ConditionList != null && info.ConditionList.Count > 0)
{
_statusTriggerConditionInfoRepository.EntityContext.Deleteable<StatusTriggerConditionInfo>() _statusTriggerConditionInfoRepository.EntityContext.Deleteable<StatusTriggerConditionInfo>()
.EnableQueryFilter().Where(a => a.P_ID == entity.PK_ID).ExecuteCommand(); .EnableQueryFilter().Where(a => a.P_ID == entity.PK_ID).ExecuteCommand();
_statusTriggerConditionInfoRepository.EntityContext.Deleteable<StatusTriggerConditionNextActInfo>()
.EnableQueryFilter().Where(a => a.TRIGGER_ID == entity.PK_ID).ExecuteCommand();
if (info.ConditionList != null && info.ConditionList.Count > 0)
{
info.ConditionList.ForEach(async cd => { info.ConditionList.ForEach(async cd => {
var conditionModel = cd.Adapt<StatusTriggerConditionInfo>(); var conditionModel = cd.Adapt<StatusTriggerConditionInfo>();
conditionModel.PK_ID = IDGen.NextID().ToString();
conditionModel.P_ID = entity.PK_ID;
conditionModel.CreatedTime = DateTime.Now;
conditionModel.CreatedUserId = UserManager.UserId;
conditionModel.CreatedUserName = UserManager.Name;
conditionModel.IsDeleted = false;
await _statusTriggerConditionInfoRepository.InsertAsync(conditionModel); await _statusTriggerConditionInfoRepository.InsertAsync(conditionModel);
if (cd.NextActionType == StatusTriggerNextActionTypeEnum.TRIGGER_ACTIVITIES.ToString())
{
if (cd.NextActList != null && cd.NextActList.Count > 0)
{
//写入需要触发的其他流程活动
cd.NextActList.ForEach(async nxt => {
var nextModel = new StatusTriggerConditionNextActInfo
{
PK_ID = IDGen.NextID().ToString(),
CONDITION_ID = conditionModel.PK_ID,
TRIGGER_ID = entity.PK_ID,
SERVICE_ACTIVITIES_ID = nxt.ServiceActivitiesID,
SHOW_NAME = nxt.ShowName,
};
await _statusTriggerConditionNextActInfoRepository.InsertAsync(nextModel);
});
}
}
}); });
} }
} }
@ -187,6 +247,7 @@ namespace Myshipping.Application
if (model == null) if (model == null)
throw Oops.Oh($"触发器获取失败,触发器信息不存在或已作废", typeof(InvalidOperationException)); throw Oops.Oh($"触发器获取失败,触发器信息不存在或已作废", typeof(InvalidOperationException));
return model; return model;
} }
#endregion #endregion
@ -493,6 +554,30 @@ namespace Myshipping.Application
var showModel = model.Adapt<StatusTriggerBaseShowDto>(); var showModel = model.Adapt<StatusTriggerBaseShowDto>();
var list = _statusTriggerConditionInfoRepository.AsQueryable().Filter(null, true)
.LeftJoin<StatusTriggerConditionNextActInfo>((cod, nxt) =>
cod.PK_ID == nxt.CONDITION_ID)
.Where((cod, nxt) => cod.P_ID == showModel.PKId)
.Select((cod, nxt) => new { Cod = cod, Next = nxt })
.ToList();
if (list.Count > 0)
{
showModel.ConditionList = list.GroupBy(a => a.Cod.PK_ID)
.Select(a => {
var currList = a.ToList();
var codDto = currList.FirstOrDefault().Cod.Adapt<StatusTriggerConditionDto>();
if(currList.Any(b=>b.Next != null))
codDto.NextActList = currList.Select(b=>b.Next).ToList()
.Adapt<List<StatusTriggerConditionNextActDto>>();
return codDto;
}).ToList();
}
result.succ = true; result.succ = true;
result.ext = showModel; result.ext = showModel;
} }
@ -629,6 +714,11 @@ namespace Myshipping.Application
isShowDays = true; isShowDays = true;
} }
if (s.IndexOf(",") >= 0)
{
s = s.Substring(0, s.IndexOf(","));
}
var model = new TriggerOperTypeDto { var model = new TriggerOperTypeDto {
Code = a.Key, Code = a.Key,
Name = s, Name = s,
@ -648,6 +738,56 @@ namespace Myshipping.Application
return result; return result;
} }
/// <summary>
/// 获取状态触发器触发动作列表
/// </summary>
/// <returns>返回回执</returns>
[HttpGet("/StatusTriggerBase/GetTriggerNextActionTypeList")]
public async Task<TaskManageOrderResultDto> GetTriggerNextActionTypeList()
{
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
try
{
var dict = EnumUtil.GetEnumDictionaryWithKey(typeof(StatusTriggerNextActionTypeEnum));
result.succ = true;
if (dict.Count > 0)
{
result.ext = dict.Select(a => {
var s = a.Value;
bool isShowActivities = false;
if (Regex.IsMatch(s, "\\#SHOWACTS\\#"))
{
s = Regex.Replace(s, "\\#SHOWACTS\\#", "");
isShowActivities = true;
}
if (s.IndexOf(",") >= 0)
{
s = s.Substring(0, s.IndexOf(","));
}
var model = new TriggerNextActionTypeDto
{
Code = a.Key,
Name = s,
IsShowActivities = isShowActivities
};
return model;
}).ToList();
}
}
catch (Exception ex)
{
result.succ = false;
result.msg = $"保存服务项目异常,原因:{ex.Message}";
}
return result;
}
/// <summary> /// <summary>
/// 生成LIQUID表达式 /// 生成LIQUID表达式
/// </summary> /// </summary>
@ -660,11 +800,81 @@ namespace Myshipping.Application
try try
{ {
//var id = await InnerSave(info); if(string.IsNullOrWhiteSpace(info.ServiceActivitiesID))
{
_logger.LogInformation("服务活动不能为空");
throw Oops.Oh($"服务活动不能为空", typeof(InvalidOperationException));
}
if (string.IsNullOrWhiteSpace(info.OperType))
{
_logger.LogInformation("操作类型不能为空");
throw Oops.Oh($"操作类型不能为空", typeof(InvalidOperationException));
}
if (string.IsNullOrWhiteSpace(info.NextActionType))
{
_logger.LogInformation("触发类型不能为空");
throw Oops.Oh($"触发类型不能为空", typeof(InvalidOperationException));
}
string s = string.Empty;
s += "{{ if isyield "+ GetLiquidOperator(info.OperType) + " 1 }}";
if(info.NextActionType.Equals(StatusTriggerNextActionTypeEnum.TRIGGER_ACTIVITIES.ToString(),
StringComparison.OrdinalIgnoreCase))
{
s += " EXEC_ACT ";
}
else
{
s += " SEND_MSG ";
}
s += "{{ end }}";
result.succ = true; result.succ = true;
//result.msg = "保存成功"; result.ext = s;
//result.ext = id; }
catch (Exception ex)
{
result.succ = false;
result.msg = $"保存服务项目异常,原因:{ex.Message}";
}
return result;
}
private string GetLiquidOperator(string code)
{
var dict = EnumUtil.GetEnumDictionaryWithKey(typeof(StatusTriggerOperTypeEnum));
if (dict.Keys.Any(a=>a.Equals(code,StringComparison.OrdinalIgnoreCase)))
{
var s = dict[code];
return s.Split(new char[] { ',' }).LastOrDefault();
}
return String.Empty;
}
/// <summary>
/// 测试LIQUID表达式
/// </summary>
/// <param name="info">状态触发器条件详情</param>
/// <param name="liquidExpress">LIQUID表达式</param>
/// <returns>返回回执</returns>
[HttpPost("/StatusTriggerBase/TestLiquidExpression")]
public async Task<TaskManageOrderResultDto> TestLiquidExpression(StatusTriggerConditionDto info, string liquidExpress)
{
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
try
{
} }
catch (Exception ex) catch (Exception ex)
{ {

Loading…
Cancel
Save