diff --git a/Myshipping.Application/Entity/TrackingSystem/ServiceWorkFlowActivitiesInfo.cs b/Myshipping.Application/Entity/TrackingSystem/ServiceWorkFlowActivitiesInfo.cs
index 8e1d8890..314189a8 100644
--- a/Myshipping.Application/Entity/TrackingSystem/ServiceWorkFlowActivitiesInfo.cs
+++ b/Myshipping.Application/Entity/TrackingSystem/ServiceWorkFlowActivitiesInfo.cs
@@ -1,4 +1,5 @@
-using Myshipping.Core;
+using Myshipping.Application.Entity.TrackingSystem;
+using Myshipping.Core;
using SqlSugar;
using System;
using System.Collections.Generic;
@@ -12,22 +13,10 @@ namespace Myshipping.Application.Entity
///
/// 服务流程活动表
///
- [Tenant(CommonConst.MasterDb)]
[SugarTable("service_workflow_activities")]
[Description("服务流程活动表")]
- public class ServiceWorkFlowActivitiesInfo
+ public class ServiceWorkFlowActivitiesInfo : TrackingSystemDbEntity
{
- ///
- /// 主键
- ///
- [SugarColumn(ColumnDescription = "主键", IsPrimaryKey = true)]
- public string PK_ID { get; set; }
-
- ///
- /// 服务流程主键
- ///
- public string SERVICE_WORKFLOW_ID { get; set; }
-
///
/// 状态主键
///
@@ -38,9 +27,5 @@ namespace Myshipping.Application.Entity
///
public string SHOW_NAME { get; set; }
- ///
- /// 显示顺序号
- ///
- public int SORT_NO { get; set; }
}
}
diff --git a/Myshipping.Application/Entity/TrackingSystem/ServiceWorkFlowActivitiesRelation.cs b/Myshipping.Application/Entity/TrackingSystem/ServiceWorkFlowActivitiesRelation.cs
new file mode 100644
index 00000000..e0ffd0ac
--- /dev/null
+++ b/Myshipping.Application/Entity/TrackingSystem/ServiceWorkFlowActivitiesRelation.cs
@@ -0,0 +1,38 @@
+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
+{
+ [Tenant(CommonConst.MasterDb)]
+ [SugarTable("service_workflow_activities_relation")]
+ [Description("服务流程与服务流程活动关系表")]
+ public class ServiceWorkFlowActivitiesRelation
+ {
+ ///
+ /// 主键
+ ///
+ [SugarColumn(ColumnDescription = "主键", IsPrimaryKey = true)]
+ public string PK_ID { get; set; }
+
+ ///
+ /// 服务流程主键
+ ///
+ public string SERVICE_WORKFLOW_ID { get; set; }
+
+ ///
+ /// 服务项目主键
+ ///
+ public string SERVICE_ACTIVITIES_ID { get; set; }
+
+ ///
+ /// 显示顺序号
+ ///
+ public int SORT_NO { get; set; }
+ }
+}
diff --git a/Myshipping.Application/Entity/TrackingSystem/ServiceWorkFlowBaseInfo.cs b/Myshipping.Application/Entity/TrackingSystem/ServiceWorkFlowBaseInfo.cs
index 17db1bc4..9d479539 100644
--- a/Myshipping.Application/Entity/TrackingSystem/ServiceWorkFlowBaseInfo.cs
+++ b/Myshipping.Application/Entity/TrackingSystem/ServiceWorkFlowBaseInfo.cs
@@ -79,5 +79,11 @@ namespace Myshipping.Application.Entity
/// 发布人名称
///
public string PUBLISH_NAME { get; set; }
+
+ ///
+ /// 是否锁止 1-锁止(不允许修改,只能取消锁止后才能修改) 0-未锁止
+ ///
+
+ public int IS_LOCK { get; set; } = 0;
}
}
diff --git a/Myshipping.Application/Entity/TrackingSystem/ServiceWorkFlowRunActivitiesInfo.cs b/Myshipping.Application/Entity/TrackingSystem/ServiceWorkFlowRunActivitiesInfo.cs
index a714a34b..c15403a2 100644
--- a/Myshipping.Application/Entity/TrackingSystem/ServiceWorkFlowRunActivitiesInfo.cs
+++ b/Myshipping.Application/Entity/TrackingSystem/ServiceWorkFlowRunActivitiesInfo.cs
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace Myshipping.Application.Entity
{
- internal class ServiceWorkFlowRunActivitiesInfo
+ public class ServiceWorkFlowRunActivitiesInfo
{
}
}
diff --git a/Myshipping.Application/Entity/TrackingSystem/ServiceWorkFlowRunInfo.cs b/Myshipping.Application/Entity/TrackingSystem/ServiceWorkFlowRunInfo.cs
index f0ed0ef8..4f0cc363 100644
--- a/Myshipping.Application/Entity/TrackingSystem/ServiceWorkFlowRunInfo.cs
+++ b/Myshipping.Application/Entity/TrackingSystem/ServiceWorkFlowRunInfo.cs
@@ -1,12 +1,72 @@
-using System;
+using Furion.DistributedIDGenerator;
+using Myshipping.Application.Entity.TrackingSystem;
+using SqlSugar;
+using System;
using System.Collections.Generic;
+using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Myshipping.Application.Entity
{
- internal class ServiceWorkFlowRunInfo
+ ///
+ /// 服务流程运行主表
+ ///
+ [SugarTable("service_workflow_run")]
+ [Description("服务流程主表")]
+ public class ServiceWorkFlowRunInfo : TrackingSystemDbEntity
{
+ public ServiceWorkFlowRunInfo()
+ {
+ PK_ID = IDGen.NextID().ToString();
+
+ CreatedTime = DateTime.Now;
+ }
+
+ ///
+ /// 服务流程主键
+ ///
+ public string SERVICE_WF_ID { get; set; }
+
+ ///
+ /// 业务系统代码
+ ///
+ public string BUSI_SYSTEM_CODE { get; set; }
+
+ ///
+ /// 业务主键
+ ///
+ public string BUSI_ID { get; set; }
+
+ ///
+ /// 提单号
+ ///
+ public string MBL_NO { get; set; }
+
+ ///
+ /// 船名航次
+ ///
+ public string VESSEL_VOYNO { get; set; }
+
+ ///
+ /// 订舱编号
+ ///
+ public string ORDER_NO { get; set; }
+
+ ///
+ /// 状态
+ ///
+ public string STATUS { get; set; }
+
+ ///
+ /// 活动数量
+ ///
+ public int ACTIVITIES_NUM { get; set; }
+
+ ///
+ /// 最后活动名称
+ ///
+ public int LST_ACT_NAME { get; set; }
}
}
diff --git a/Myshipping.Application/Entity/TrackingSystem/StatusTriggerBaseInfo.cs b/Myshipping.Application/Entity/TrackingSystem/StatusTriggerBaseInfo.cs
index e0ad3012..f218dbc2 100644
--- a/Myshipping.Application/Entity/TrackingSystem/StatusTriggerBaseInfo.cs
+++ b/Myshipping.Application/Entity/TrackingSystem/StatusTriggerBaseInfo.cs
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace Myshipping.Application.Entity
{
- internal class StatusTriggerBaseInfo
+ public class StatusTriggerBaseInfo
{
}
}
diff --git a/Myshipping.Application/Service/TrackingSystem/Dtos/QueryServiceWorkFlowBaseDto.cs b/Myshipping.Application/Service/TrackingSystem/Dtos/QueryServiceWorkFlowBaseDto.cs
index 5772c72f..12aff2eb 100644
--- a/Myshipping.Application/Service/TrackingSystem/Dtos/QueryServiceWorkFlowBaseDto.cs
+++ b/Myshipping.Application/Service/TrackingSystem/Dtos/QueryServiceWorkFlowBaseDto.cs
@@ -32,6 +32,18 @@ namespace Myshipping.Application
///
public string UpdateEnd { get; set; }
+ ///
+ /// 发布日期起始
+ ///
+ ///
+ public string PublishBegin { get; set; }
+
+ ///
+ /// 发布日期结束
+ ///
+ ///
+ public string PublishEnd { get; set; }
+
///
/// 创建人
///
diff --git a/Myshipping.Application/Service/TrackingSystem/Dtos/ServiceProjectBaseDto.cs b/Myshipping.Application/Service/TrackingSystem/Dtos/ServiceProjectBaseDto.cs
index ff5a9c7e..dcd6daed 100644
--- a/Myshipping.Application/Service/TrackingSystem/Dtos/ServiceProjectBaseDto.cs
+++ b/Myshipping.Application/Service/TrackingSystem/Dtos/ServiceProjectBaseDto.cs
@@ -31,11 +31,6 @@ namespace Myshipping.Application
///
public int SortNo { get; set; }
- ///
- /// 是否启用
- ///
- public int IsEnable { get; set; }
-
///
/// 服务项目说明
///
diff --git a/Myshipping.Application/Service/TrackingSystem/Dtos/ServiceProjectBaseShowDto.cs b/Myshipping.Application/Service/TrackingSystem/Dtos/ServiceProjectBaseShowDto.cs
index b8a97dd6..94f7ea9a 100644
--- a/Myshipping.Application/Service/TrackingSystem/Dtos/ServiceProjectBaseShowDto.cs
+++ b/Myshipping.Application/Service/TrackingSystem/Dtos/ServiceProjectBaseShowDto.cs
@@ -40,5 +40,10 @@ namespace Myshipping.Application
/// 修改人名称
///
public string UpdatedUserName { get; set; }
+
+ ///
+ /// 是否启用 1-启用 0-未启用
+ ///
+ public int IsEnable { get; set; }
}
}
diff --git a/Myshipping.Application/Service/TrackingSystem/Dtos/ServiceWorkFlowActivitiesDto.cs b/Myshipping.Application/Service/TrackingSystem/Dtos/ServiceWorkFlowActivitiesDto.cs
index 8f1f19b9..6ebc4dae 100644
--- a/Myshipping.Application/Service/TrackingSystem/Dtos/ServiceWorkFlowActivitiesDto.cs
+++ b/Myshipping.Application/Service/TrackingSystem/Dtos/ServiceWorkFlowActivitiesDto.cs
@@ -16,11 +16,6 @@ namespace Myshipping.Application
///
public string PKId { get; set; }
- ///
- /// 服务流程主键
- ///
- public string ServiceWorkflowId { get; set; }
-
///
/// 状态主键
///
diff --git a/Myshipping.Application/Service/TrackingSystem/Dtos/ServiceWorkFlowBaseDto.cs b/Myshipping.Application/Service/TrackingSystem/Dtos/ServiceWorkFlowBaseDto.cs
index 8c8308b3..f8969d7f 100644
--- a/Myshipping.Application/Service/TrackingSystem/Dtos/ServiceWorkFlowBaseDto.cs
+++ b/Myshipping.Application/Service/TrackingSystem/Dtos/ServiceWorkFlowBaseDto.cs
@@ -14,43 +14,39 @@ namespace Myshipping.Application
///
/// 主键
///
+ ///
public string PKId { get; set; }
///
/// 服务流程代码
///
+ /// WF_TEST1
public string ServiceWorkflowCode { get; set; }
///
/// 服务流程名称
///
+ /// 测试服务流程1
public string ServiceWorkflowName { get; set; }
///
/// 服务流程说明
///
+ /// 测试服务流程1
public string ServiceWorkflowNote { get; set; }
///
/// 所属租户ID
///
+ ///
public long BelongTenantId { get; set; }
///
/// 所属租户名称
///
+ ///
public string BelongTenantName { get; set; }
- ///
- /// 发布人
- ///
- public long PublishEr { get; set; }
-
- ///
- /// 发布人名称
- ///
- public string PublishName { get; set; }
-
///
/// 服务项目
///
diff --git a/Myshipping.Application/Service/TrackingSystem/Dtos/ServiceWorkFlowBaseShowDto.cs b/Myshipping.Application/Service/TrackingSystem/Dtos/ServiceWorkFlowBaseShowDto.cs
index fc374fa3..4031fe6a 100644
--- a/Myshipping.Application/Service/TrackingSystem/Dtos/ServiceWorkFlowBaseShowDto.cs
+++ b/Myshipping.Application/Service/TrackingSystem/Dtos/ServiceWorkFlowBaseShowDto.cs
@@ -85,5 +85,15 @@ namespace Myshipping.Application
/// 发布版本
///
public string ReleaseVersion { get; set; }
+
+ ///
+ /// 发布人
+ ///
+ public long PublishEr { get; set; }
+
+ ///
+ /// 发布人名称
+ ///
+ public string PublishName { get; set; }
}
}
diff --git a/Myshipping.Application/Service/TrackingSystem/Dtos/TrackingSystemMapper.cs b/Myshipping.Application/Service/TrackingSystem/Dtos/TrackingSystemMapper.cs
index 1678d48e..559ac9d1 100644
--- a/Myshipping.Application/Service/TrackingSystem/Dtos/TrackingSystemMapper.cs
+++ b/Myshipping.Application/Service/TrackingSystem/Dtos/TrackingSystemMapper.cs
@@ -110,6 +110,10 @@ namespace Myshipping.Application
.Map(dest => dest.BelongTenantName, src => src.BELONG_TENANT_NAME)
.Map(dest => dest.StatusNum, src => src.STATUS_NUM);
+ config.ForType()
+ .Map(dest => dest.PK_ID, src => src.PKId)
+ .Map(dest => dest.STATUS_SKU_ID, src => src.StatusSKUId)
+ .Map(dest => dest.SHOW_NAME, src => src.ShowName);
}
}
}
diff --git a/Myshipping.Application/Service/TrackingSystem/Interface/IServiceWorkFlowBaseService.cs b/Myshipping.Application/Service/TrackingSystem/Interface/IServiceWorkFlowBaseService.cs
index 181913b1..c12c9644 100644
--- a/Myshipping.Application/Service/TrackingSystem/Interface/IServiceWorkFlowBaseService.cs
+++ b/Myshipping.Application/Service/TrackingSystem/Interface/IServiceWorkFlowBaseService.cs
@@ -91,5 +91,12 @@ namespace Myshipping.Application
/// 服务流程主键
/// 返回回执
Task GetShowTimeLine(string pkId);
+
+ ///
+ /// 保存服务流程活动
+ ///
+ /// 保存服务流程活动详情
+ /// 返回回执
+ Task SaveWFActivities(ServiceWorkFlowActivitiesDto info);
}
}
diff --git a/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowBaseService.cs b/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowBaseService.cs
index 979dfcf6..c556c6d0 100644
--- a/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowBaseService.cs
+++ b/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowBaseService.cs
@@ -26,14 +26,24 @@ namespace Myshipping.Application
{
private readonly SqlSugarRepository _serviceWorkFlowBaseRepository;
private readonly SqlSugarRepository _serviceWorkFlowActivitiesInfoRepository;
+ private readonly SqlSugarRepository _serviceWorkFlowProjectRelationRepository;
+ private readonly SqlSugarRepository _serviceWorkFlowActivitiesRelationRepository;
+
+
private readonly ILogger _logger;
public ServiceWorkFlowBaseService(SqlSugarRepository serviceWorkFlowBaseRepository,
- ILogger logger,
- SqlSugarRepository serviceWorkFlowActivitiesInfoRepository)
+ ILogger logger,
+ SqlSugarRepository serviceWorkFlowActivitiesInfoRepository,
+ SqlSugarRepository serviceWorkFlowProjectRelationRepository,
+ SqlSugarRepository serviceWorkFlowActivitiesRelationRepository)
{
_serviceWorkFlowBaseRepository = serviceWorkFlowBaseRepository;
_serviceWorkFlowActivitiesInfoRepository = serviceWorkFlowActivitiesInfoRepository;
+ _serviceWorkFlowProjectRelationRepository = serviceWorkFlowProjectRelationRepository;
+ _serviceWorkFlowActivitiesRelationRepository = serviceWorkFlowActivitiesRelationRepository;
+
+ _logger = logger;
}
///
@@ -63,11 +73,104 @@ namespace Myshipping.Application
return result;
}
+ #region 保存服务流程活动
+ ///
+ /// 保存服务流程活动
+ ///
+ /// 保存服务流程活动详情
+ /// 返回回执
+ [HttpPost("/ServiceWorkFlowBase/SaveWFActivities")]
+ public async Task SaveWFActivities([FromBody] ServiceWorkFlowActivitiesDto info)
+ {
+ TaskManageOrderResultDto result = new TaskManageOrderResultDto();
+
+ try
+ {
+ /*
+ 1、状态有记录。
+ 2、同一状态不能有相同的显示名称
+ 3、已经关联服务流程的,并且已经发布的不能修改内容。(只可以新增)
+ */
+ var entity = info.Adapt();
+
+ if (string.IsNullOrWhiteSpace(entity.STATUS_SKU_ID))
+ {
+ throw Oops.Oh($"状态不能为空", typeof(InvalidOperationException));
+ }
+
+ if (string.IsNullOrWhiteSpace(entity.SHOW_NAME) || entity.SHOW_NAME.Length < 2)
+ {
+ throw Oops.Oh($"状态显示名称不能为空,并且不能少于2个字符", typeof(InvalidOperationException));
+ }
+
+ //同一状态不能有相同的显示名称
+ var checkList = _serviceWorkFlowActivitiesInfoRepository.AsQueryable()
+ .Where(a=>a.STATUS_SKU_ID == entity.STATUS_SKU_ID
+ && a.SHOW_NAME == entity.SHOW_NAME && a.PK_ID != entity.PK_ID).ToList();
+
+ if (checkList.Count > 0)
+ throw Oops.Oh($"已存在相同的状态设置,不能保存", typeof(InvalidOperationException));
+
+ //_logger.LogInformation($"服务项目保存 JSON={JSON.Serialize(entity)} user={UserManager.UserId}");
+
+ if (string.IsNullOrWhiteSpace(entity.PK_ID))
+ {
+ entity.PK_ID = IDGen.NextID().ToString();
+
+ _serviceWorkFlowActivitiesInfoRepository.Insert(entity);
+ }
+ else
+ {
+ //已经关联服务流程的,并且已经发布的不能修改内容。(只可以新增)
+ var wfRelation = _serviceWorkFlowActivitiesRelationRepository.AsQueryable()
+ .Where(a=>a.SERVICE_ACTIVITIES_ID == entity.PK_ID)
+ .ToList();
+
+ if (wfRelation.Count > 0)
+ {
+ var currArg = wfRelation.Select(a=>a.SERVICE_WORKFLOW_ID).Distinct().ToList();
+
+ if (_serviceWorkFlowBaseRepository.AsQueryable().Any(a => currArg.Any(b => b == a.PK_ID)
+ && (!string.IsNullOrWhiteSpace(a.RELEASE_VERSION) || a.IS_LOCK == 1)))
+ {
+ throw Oops.Oh($"当前状态已关联发布流程,不能保存", typeof(InvalidOperationException));
+ }
+ }
+
+ entity.UpdatedTime = DateTime.Now;
+ entity.UpdatedUserId = UserManager.UserId;
+ entity.UpdatedUserName = UserManager.Name;
+
+ await _serviceWorkFlowActivitiesInfoRepository.AsUpdateable(entity).IgnoreColumns(it => new
+ {
+ it.TenantId,
+ it.TenantName,
+ it.CreatedTime,
+ it.CreatedUserId,
+ it.CreatedUserName,
+ it.IsDeleted,
+ }).ExecuteCommandAsync();
+ }
+
+ result.succ = true;
+ result.msg = "保存成功";
+ result.ext = entity.PK_ID;
+ }
+ catch (Exception ex)
+ {
+ result.succ = false;
+ result.msg = $"保存服务流程活动异常,原因:{ex.Message}";
+ }
+
+ return result;
+ }
+ #endregion
+
#region 保存内部方法
///
/// 保存内部方法
///
- /// 服务项目详情
+ /// 服务流程详情
/// 是否启用
/// 返回派车Id
[SqlSugarUnitOfWork]
@@ -81,9 +184,9 @@ namespace Myshipping.Application
}
if (entity == null)
- throw Oops.Oh($"服务项目不能为空", typeof(InvalidOperationException));
+ throw Oops.Oh($"服务流程不能为空", typeof(InvalidOperationException));
- _logger.LogInformation($"服务项目保存 JSON={JSON.Serialize(entity)} user={UserManager.UserId}");
+ _logger.LogInformation($"服务流程保存 JSON={JSON.Serialize(entity)} user={UserManager.UserId}");
if (string.IsNullOrWhiteSpace(entity.PK_ID))
{
@@ -96,11 +199,8 @@ namespace Myshipping.Application
var model = InnerGetInfo(entity.PK_ID);
_logger.LogInformation($"更新状态前,获取原始记录 JSON={JSON.Serialize(model)}");
-
- //if (!entity.STATUS_SKU_CODE.Equals(model.STATUS_SKU_CODE, StringComparison.OrdinalIgnoreCase))
- //{
- // ValidateServiceProject(entity, true);
- //}
+
+ ValidateServiceWorkFlow(entity, true);
entity.UpdatedTime = DateTime.Now;
entity.UpdatedUserId = UserManager.UserId;
@@ -116,6 +216,41 @@ namespace Myshipping.Application
it.IsDeleted,
}).ExecuteCommandAsync();
+ //批量删除服务流程与服务项目关系(物理删除)
+ _serviceWorkFlowProjectRelationRepository.EntityContext.Deleteable()
+ .Where(a => a.SERVICE_WORKFLOW_ID == entity.PK_ID);
+
+ //批量删除服务流程与服务活动关系(物理删除)
+ _serviceWorkFlowActivitiesRelationRepository.EntityContext.Deleteable()
+ .Where(a => a.SERVICE_WORKFLOW_ID == entity.PK_ID);
+ }
+
+ //服务流程与服务项目关系
+ if (info.ServiceProject != null && !string.IsNullOrWhiteSpace(info.ServiceProject.PKId))
+ {
+ var wfRelationProject = new ServiceWorkFlowProjectRelation {
+ PK_ID = IDGen.NextID().ToString(),
+ SERVICE_WORKFLOW_ID = entity.PK_ID,
+ SERVICE_PROJECT_ID = info.ServiceProject.PKId,
+ };
+
+ //插入关系
+ await _serviceWorkFlowProjectRelationRepository.InsertAsync(wfRelationProject);
+ }
+
+ //服务流程与服务活动关系
+ if (info.StatusSkuList != null && info.StatusSkuList.Count > 0)
+ {
+ info.StatusSkuList.ForEach(async sku =>
+ {
+ var wfRelationActivities = new ServiceWorkFlowActivitiesRelation {
+ PK_ID = IDGen.NextID().ToString(),
+ SERVICE_WORKFLOW_ID = entity.PK_ID,
+ SERVICE_ACTIVITIES_ID = sku.PKId,
+ };
+
+ await _serviceWorkFlowActivitiesRelationRepository.InsertAsync();
+ });
}
return entity.PK_ID;
@@ -129,8 +264,11 @@ namespace Myshipping.Application
/// 服务项目详情
/// 是否校验关系
///
- private void ValidateServiceProject(ServiceWorkFlowBaseInfo entity, bool isCheckRelation = false)
+ private void ValidateServiceWorkFlow(ServiceWorkFlowBaseInfo entity, bool isCheckRelation = false)
{
+ /*
+
+ */
//if (isCheckRelation && _serviceWorkFlowActivitiesInfoRepository.Any(a => a.STATUS_SKU_ID == entity.PK_ID))
//{
// _logger.LogInformation($"当前状态已关联服务流程不能修改");