diff --git a/Myshipping.Application/Entity/TrackingSystem/StatusTriggerConditionNextActInfo.cs b/Myshipping.Application/Entity/TrackingSystem/StatusTriggerConditionNextActInfo.cs
new file mode 100644
index 00000000..324df69f
--- /dev/null
+++ b/Myshipping.Application/Entity/TrackingSystem/StatusTriggerConditionNextActInfo.cs
@@ -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
+{
+ ///
+ /// 触发器条件触发其他流程活动
+ ///
+ [SugarTable("status_trigger_condition_next_act")]
+ [Description("触发器条件触发其他流程活动")]
+ [Tenant(CommonConst.MasterDb)]
+ public class StatusTriggerConditionNextActInfo
+ {
+ ///
+ /// 主键
+ ///
+ [SugarColumn(ColumnDescription = "主键", IsPrimaryKey = true)]
+ public string PK_ID { get; set; }
+
+ ///
+ /// 触发器主键
+ ///
+ public string TRIGGER_ID { get; set; }
+
+ ///
+ /// 条件ID
+ ///
+ public string CONDITION_ID { get; set; }
+
+ ///
+ /// 服务活动主键
+ ///
+ public string SERVICE_ACTIVITIES_ID { get; set; }
+
+ ///
+ /// 状态显示名称
+ ///
+ public string SHOW_NAME { get; set; }
+ }
+}
diff --git a/Myshipping.Application/Enum/StatusTriggerNextActionTypeEnum.cs b/Myshipping.Application/Enum/StatusTriggerNextActionTypeEnum.cs
new file mode 100644
index 00000000..972ceddf
--- /dev/null
+++ b/Myshipping.Application/Enum/StatusTriggerNextActionTypeEnum.cs
@@ -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
+{
+ ///
+ /// 触发器触发动作枚举
+ ///
+ public enum StatusTriggerNextActionTypeEnum
+ {
+ ///
+ /// 消息提醒
+ ///
+ [Description("消息提醒")]
+ MESSAGE_CAUTION,
+ ///
+ /// 触发其他状态
+ ///
+ [Description("触发其他状态#SHOWACTS#")]
+ TRIGGER_ACTIVITIES
+ }
+}
diff --git a/Myshipping.Application/Enum/StatusTriggerOperTypeEnum.cs b/Myshipping.Application/Enum/StatusTriggerOperTypeEnum.cs
index fbcde392..84524835 100644
--- a/Myshipping.Application/Enum/StatusTriggerOperTypeEnum.cs
+++ b/Myshipping.Application/Enum/StatusTriggerOperTypeEnum.cs
@@ -15,47 +15,52 @@ namespace Myshipping.Application
///
/// 第(N)天后
///
- [Description("第(N)天后#DAYS#")]
+ [Description("第(N)天后#DAYS#,func_DelayExcuteRun")]
DATE_NEXT_DAY,
///
+ /// 已完成
+ ///
+ [Description("已完成,func_DelayExcuteRun")]
+ IS_YIELD,
+ ///
/// 等于
///
- [Description("等于")]
+ [Description("等于,==")]
EQUALS,
///
/// 不等于
///
- [Description("不等于")]
+ [Description("不等于,!=")]
DOES_NOT_EQUAL,
///
/// 大于
///
- [Description("大于")]
+ [Description("大于,>")]
GREATER_THAN,
///
/// 大于等于
///
- [Description("大于等于")]
+ [Description("大于等于,>=")]
GREATER_THEN_EQUAL,
///
/// 小于
///
- [Description("小于")]
+ [Description("小于,<")]
LESS_THAN,
///
/// 小于等于
///
- [Description("小于等于")]
+ [Description("小于等于,<=")]
LESS_THAN_EQUAL,
///
/// 或者
///
- [Description("或者")]
+ [Description("或者,&&")]
LOGICAL_OR,
///
/// 并且
///
- [Description("并且")]
+ [Description("并且,||")]
LOGICAL_AND
diff --git a/Myshipping.Application/Myshipping.Application.csproj b/Myshipping.Application/Myshipping.Application.csproj
index 8e0fcf48..902f9739 100644
--- a/Myshipping.Application/Myshipping.Application.csproj
+++ b/Myshipping.Application/Myshipping.Application.csproj
@@ -38,6 +38,7 @@
+
diff --git a/Myshipping.Application/Service/TrackingSystem/Dtos/ServiceWorkFlowActivitiesDto.cs b/Myshipping.Application/Service/TrackingSystem/Dtos/ServiceWorkFlowActivitiesDto.cs
index e334f857..4bced971 100644
--- a/Myshipping.Application/Service/TrackingSystem/Dtos/ServiceWorkFlowActivitiesDto.cs
+++ b/Myshipping.Application/Service/TrackingSystem/Dtos/ServiceWorkFlowActivitiesDto.cs
@@ -45,6 +45,11 @@ namespace Myshipping.Application
/// 子活动列表
///
public List SubList { get; set; }
+
+ ///
+ /// 触发器列表
+ ///
+ public List StatusTriggerList { get; set; }
}
diff --git a/Myshipping.Application/Service/TrackingSystem/Dtos/StatusTriggerConditionDto.cs b/Myshipping.Application/Service/TrackingSystem/Dtos/StatusTriggerConditionDto.cs
index 5342dfcf..769881bb 100644
--- a/Myshipping.Application/Service/TrackingSystem/Dtos/StatusTriggerConditionDto.cs
+++ b/Myshipping.Application/Service/TrackingSystem/Dtos/StatusTriggerConditionDto.cs
@@ -56,5 +56,9 @@ namespace Myshipping.Application
///
public string LiquidExpression { get; set; }
+ ///
+ /// 触发其他流程活动列表
+ ///
+ public List NextActList { get; set; }
}
}
diff --git a/Myshipping.Application/Service/TrackingSystem/Dtos/StatusTriggerConditionNextActDto.cs b/Myshipping.Application/Service/TrackingSystem/Dtos/StatusTriggerConditionNextActDto.cs
new file mode 100644
index 00000000..e2b9c557
--- /dev/null
+++ b/Myshipping.Application/Service/TrackingSystem/Dtos/StatusTriggerConditionNextActDto.cs
@@ -0,0 +1,39 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Myshipping.Application
+{
+ ///
+ ///
+ ///
+ public class StatusTriggerConditionNextActDto
+ {
+ ///
+ /// 主键
+ ///
+ public string PKId { get; set; }
+
+ ///
+ /// 触发器主键
+ ///
+ public string TriggerId { get; set; }
+
+ ///
+ /// 条件ID
+ ///
+ public string ConditionId { get; set; }
+
+ ///
+ /// 服务活动主键
+ ///
+ public string ServiceActivitiesID { get; set; }
+
+ ///
+ /// 状态显示名称
+ ///
+ public string ShowName { get; set; }
+ }
+}
diff --git a/Myshipping.Application/Service/TrackingSystem/Dtos/TrackingSystemMapper.cs b/Myshipping.Application/Service/TrackingSystem/Dtos/TrackingSystemMapper.cs
index 7b92e706..6c47a4e4 100644
--- a/Myshipping.Application/Service/TrackingSystem/Dtos/TrackingSystemMapper.cs
+++ b/Myshipping.Application/Service/TrackingSystem/Dtos/TrackingSystemMapper.cs
@@ -185,7 +185,8 @@ namespace Myshipping.Application
config.ForType()
.Map(dest => dest.PK_ID, src => src.PKId)
.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()
.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.UpdatedUserName, src => src.UpdatedUserName);
+ config.ForType()
+ .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()
+ .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);
+
}
}
}
diff --git a/Myshipping.Application/Service/TrackingSystem/Dtos/TriggerNextActionTypeDto.cs b/Myshipping.Application/Service/TrackingSystem/Dtos/TriggerNextActionTypeDto.cs
new file mode 100644
index 00000000..1277bb6a
--- /dev/null
+++ b/Myshipping.Application/Service/TrackingSystem/Dtos/TriggerNextActionTypeDto.cs
@@ -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
+ {
+ ///
+ /// 代码
+ ///
+ public string Code { get; set; }
+
+ ///
+ /// 名称
+ ///
+ public string Name { get; set; }
+
+ ///
+ /// 是否显示流程活动
+ ///
+ public bool IsShowActivities { get; set; }
+ }
+}
diff --git a/Myshipping.Application/Service/TrackingSystem/Interface/IStatusTriggerBaseService.cs b/Myshipping.Application/Service/TrackingSystem/Interface/IStatusTriggerBaseService.cs
index c3e3b3e7..45f99bb9 100644
--- a/Myshipping.Application/Service/TrackingSystem/Interface/IStatusTriggerBaseService.cs
+++ b/Myshipping.Application/Service/TrackingSystem/Interface/IStatusTriggerBaseService.cs
@@ -75,11 +75,25 @@ namespace Myshipping.Application
/// 返回回执
Task GetTriggerOperTypeList();
+ ///
+ /// 获取状态触发器触发动作列表
+ ///
+ /// 返回回执
+ Task GetTriggerNextActionTypeList();
+
///
/// 生成LIQUID表达式
///
/// 状态触发器条件详情
/// 返回回执
Task CreateLiquidExpression(StatusTriggerConditionDto info);
+
+ ///
+ /// 测试LIQUID表达式
+ ///
+ /// 状态触发器条件详情
+ /// LIQUID表达式
+ /// 返回回执
+ Task TestLiquidExpression(StatusTriggerConditionDto info, string liquidExpress);
}
}
diff --git a/Myshipping.Application/Service/TrackingSystem/StatusTriggerBaseService.cs b/Myshipping.Application/Service/TrackingSystem/StatusTriggerBaseService.cs
index 03b77813..539f6ea1 100644
--- a/Myshipping.Application/Service/TrackingSystem/StatusTriggerBaseService.cs
+++ b/Myshipping.Application/Service/TrackingSystem/StatusTriggerBaseService.cs
@@ -26,16 +26,18 @@ namespace Myshipping.Application
{
private readonly SqlSugarRepository _statusTriggerBaseInfoRepository;
private readonly SqlSugarRepository _statusTriggerConditionInfoRepository;
+ private readonly SqlSugarRepository _statusTriggerConditionNextActInfoRepository;
private readonly ILogger _logger;
public StatusTriggerBaseService(SqlSugarRepository statusTriggerBaseInfoRepository,
SqlSugarRepository statusTriggerConditionInfoRepository,
+ SqlSugarRepository statusTriggerConditionNextActInfoRepository,
ILogger logger)
{
_statusTriggerBaseInfoRepository = statusTriggerBaseInfoRepository;
_statusTriggerConditionInfoRepository = statusTriggerConditionInfoRepository;
-
+ _statusTriggerConditionNextActInfoRepository = statusTriggerConditionNextActInfoRepository;
_logger = logger;
}
@@ -126,7 +128,34 @@ namespace Myshipping.Application
info.ConditionList.ForEach(async cd => {
var conditionModel = cd.Adapt();
+
+ 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);
+
+ 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,
}).ExecuteCommandAsync();
+ _statusTriggerConditionInfoRepository.EntityContext.Deleteable()
+ .EnableQueryFilter().Where(a => a.P_ID == entity.PK_ID).ExecuteCommand();
+
+ _statusTriggerConditionInfoRepository.EntityContext.Deleteable()
+ .EnableQueryFilter().Where(a => a.TRIGGER_ID == entity.PK_ID).ExecuteCommand();
if (info.ConditionList != null && info.ConditionList.Count > 0)
{
- _statusTriggerConditionInfoRepository.EntityContext.Deleteable()
- .EnableQueryFilter().Where(a => a.P_ID == entity.PK_ID).ExecuteCommand();
-
info.ConditionList.ForEach(async cd => {
var conditionModel = cd.Adapt();
+
+ 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);
+
+ 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)
throw Oops.Oh($"触发器获取失败,触发器信息不存在或已作废", typeof(InvalidOperationException));
+
return model;
}
#endregion
@@ -493,6 +554,30 @@ namespace Myshipping.Application
var showModel = model.Adapt();
+ var list = _statusTriggerConditionInfoRepository.AsQueryable().Filter(null, true)
+ .LeftJoin((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();
+
+ if(currList.Any(b=>b.Next != null))
+ codDto.NextActList = currList.Select(b=>b.Next).ToList()
+ .Adapt>();
+
+ return codDto;
+
+ }).ToList();
+ }
+
result.succ = true;
result.ext = showModel;
}
@@ -629,6 +714,11 @@ namespace Myshipping.Application
isShowDays = true;
}
+ if (s.IndexOf(",") >= 0)
+ {
+ s = s.Substring(0, s.IndexOf(","));
+ }
+
var model = new TriggerOperTypeDto {
Code = a.Key,
Name = s,
@@ -648,6 +738,56 @@ namespace Myshipping.Application
return result;
}
+ ///
+ /// 获取状态触发器触发动作列表
+ ///
+ /// 返回回执
+ [HttpGet("/StatusTriggerBase/GetTriggerNextActionTypeList")]
+ public async Task 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;
+ }
///
/// 生成LIQUID表达式
///
@@ -660,11 +800,81 @@ namespace Myshipping.Application
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.msg = "保存成功";
- //result.ext = id;
+ result.ext = s;
+ }
+ 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;
+ }
+
+ ///
+ /// 测试LIQUID表达式
+ ///
+ /// 状态触发器条件详情
+ /// LIQUID表达式
+ /// 返回回执
+ [HttpPost("/StatusTriggerBase/TestLiquidExpression")]
+ public async Task TestLiquidExpression(StatusTriggerConditionDto info, string liquidExpress)
+ {
+ TaskManageOrderResultDto result = new TaskManageOrderResultDto();
+
+ try
+ {
+
}
catch (Exception ex)
{