|
|
@ -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();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_statusTriggerConditionInfoRepository.EntityContext.Deleteable<StatusTriggerConditionInfo>()
|
|
|
|
|
|
|
|
.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)
|
|
|
|
if (info.ConditionList != null && info.ConditionList.Count > 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_statusTriggerConditionInfoRepository.EntityContext.Deleteable<StatusTriggerConditionInfo>()
|
|
|
|
|
|
|
|
.EnableQueryFilter().Where(a => a.P_ID == entity.PK_ID).ExecuteCommand();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
{
|
|
|
|