|
|
|
@ -31,15 +31,17 @@ namespace Myshipping.Application
|
|
|
|
|
private readonly SqlSugarRepository<ServiceWorkFlowActivitiesInfo> _serviceWorkFlowActivitiesInfoRepository;
|
|
|
|
|
private readonly SqlSugarRepository<ServiceWorkFlowProjectRelation> _serviceWorkFlowProjectRelationRepository;
|
|
|
|
|
private readonly SqlSugarRepository<ServiceWorkFlowActivitiesRelation> _serviceWorkFlowActivitiesRelationRepository;
|
|
|
|
|
private readonly SqlSugarRepository<ServiceWorkFlowActivitiesSubRelation> _serviceWorkFlowActivitiesSubRelationRepository;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private readonly ILogger<ServiceWorkFlowBaseService> _logger;
|
|
|
|
|
public ServiceWorkFlowBaseService(SqlSugarRepository<ServiceWorkFlowBaseInfo> serviceWorkFlowBaseRepository,
|
|
|
|
|
ILogger<ServiceWorkFlowBaseService> logger,
|
|
|
|
|
SqlSugarRepository<ServiceWorkFlowActivitiesInfo> serviceWorkFlowActivitiesInfoRepository,
|
|
|
|
|
SqlSugarRepository<ServiceWorkFlowProjectRelation> serviceWorkFlowProjectRelationRepository,
|
|
|
|
|
SqlSugarRepository<ServiceWorkFlowActivitiesRelation> serviceWorkFlowActivitiesRelationRepository)
|
|
|
|
|
SqlSugarRepository<ServiceWorkFlowActivitiesRelation> serviceWorkFlowActivitiesRelationRepository,
|
|
|
|
|
SqlSugarRepository<ServiceWorkFlowActivitiesSubRelation> serviceWorkFlowActivitiesSubRelationRepository)
|
|
|
|
|
{
|
|
|
|
|
_serviceWorkFlowBaseRepository = serviceWorkFlowBaseRepository;
|
|
|
|
|
_serviceWorkFlowActivitiesInfoRepository = serviceWorkFlowActivitiesInfoRepository;
|
|
|
|
@ -47,6 +49,7 @@ namespace Myshipping.Application
|
|
|
|
|
_serviceWorkFlowActivitiesRelationRepository = serviceWorkFlowActivitiesRelationRepository;
|
|
|
|
|
|
|
|
|
|
_logger = logger;
|
|
|
|
|
_serviceWorkFlowActivitiesSubRelationRepository = serviceWorkFlowActivitiesSubRelationRepository;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -203,6 +206,14 @@ namespace Myshipping.Application
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation($"更新状态前,获取原始记录 JSON={JSON.Serialize(model)}");
|
|
|
|
|
|
|
|
|
|
if (info.StatusSkuList != null && info.StatusSkuList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
if (info.StatusSkuList.Any(a => a.IsContainsSub == 1 && (a.SubList == null || a.SubList.Count == 0)))
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Oh($"状态已选择包含子状态,子状态列表不能为空", typeof(InvalidOperationException));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ValidateServiceWorkFlow(entity, OperateTypeEnum.Save);
|
|
|
|
|
|
|
|
|
|
entity.UpdatedTime = DateTime.Now;
|
|
|
|
@ -226,6 +237,10 @@ namespace Myshipping.Application
|
|
|
|
|
//批量删除服务流程与服务活动关系(物理删除)
|
|
|
|
|
_serviceWorkFlowActivitiesRelationRepository.EntityContext.Deleteable<ServiceWorkFlowProjectRelation>()
|
|
|
|
|
.Where(a => a.SERVICE_WORKFLOW_ID == entity.PK_ID);
|
|
|
|
|
|
|
|
|
|
//批量删除服务流程活动与子活动的关系(物理删除)
|
|
|
|
|
_serviceWorkFlowActivitiesSubRelationRepository.EntityContext.Deleteable<ServiceWorkFlowActivitiesSubRelation>()
|
|
|
|
|
.Where(a => a.SERVICE_WORKFLOW_ID == entity.PK_ID);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//服务流程与服务项目关系
|
|
|
|
@ -250,9 +265,26 @@ namespace Myshipping.Application
|
|
|
|
|
PK_ID = IDGen.NextID().ToString(),
|
|
|
|
|
SERVICE_WORKFLOW_ID = entity.PK_ID,
|
|
|
|
|
SERVICE_ACTIVITIES_ID = sku.PKId,
|
|
|
|
|
IS_CONTAINS_SUB = sku.IsContainsSub
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
await _serviceWorkFlowActivitiesRelationRepository.InsertAsync();
|
|
|
|
|
await _serviceWorkFlowActivitiesRelationRepository.InsertAsync(wfRelationActivities);
|
|
|
|
|
|
|
|
|
|
//处理子状态
|
|
|
|
|
if(sku.IsContainsSub == 1)
|
|
|
|
|
{
|
|
|
|
|
sku.SubList.ForEach(async sub => {
|
|
|
|
|
var wfRelationActivitiesSub = new ServiceWorkFlowActivitiesSubRelation
|
|
|
|
|
{
|
|
|
|
|
PK_ID = IDGen.NextID().ToString(),
|
|
|
|
|
SERVICE_WORKFLOW_ID = entity.PK_ID,
|
|
|
|
|
SERVICE_ACTIVITIES_ID = sku.PKId,
|
|
|
|
|
SUB_SERVICE_ACTIVITIES_ID = sub.PKId
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
await _serviceWorkFlowActivitiesSubRelationRepository.InsertAsync(wfRelationActivitiesSub);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -336,18 +368,64 @@ namespace Myshipping.Application
|
|
|
|
|
.LeftJoin<ServiceWorkFlowActivitiesInfo>((rela, act) =>
|
|
|
|
|
rela.SERVICE_ACTIVITIES_ID == act.PK_ID && rela.SERVICE_WORKFLOW_ID == pkId)
|
|
|
|
|
.LeftJoin<StatusSkuBaseInfo>((rela, act, sku) => act.STATUS_SKU_ID == sku.PK_ID)
|
|
|
|
|
.Select((rela, act, sku) => new { Act = act, Sku = sku, SortNo = rela.SORT_NO }).ToList();
|
|
|
|
|
.Select((rela, act, sku) =>
|
|
|
|
|
new { Act = act, Sku = sku, SortNo = rela.SORT_NO, IsSub = rela.IS_CONTAINS_SUB })
|
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
|
|
if (activitiesList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
showModel.StatusSkuList = activitiesList.OrderBy(a=>a.SortNo)
|
|
|
|
|
showModel.StatusSkuList = activitiesList.OrderBy(a => a.SortNo)
|
|
|
|
|
.Select(a =>
|
|
|
|
|
{
|
|
|
|
|
var actModel = a.Act.Adapt<ServiceWorkFlowActivitiesShowDto>();
|
|
|
|
|
|
|
|
|
|
actModel.SortNo = a.SortNo;
|
|
|
|
|
actModel.IsContainsSub = a.IsSub;
|
|
|
|
|
actModel.statusSkuBase = a.Sku.Adapt<StatusSkuBaseDto>();
|
|
|
|
|
|
|
|
|
|
return actModel;
|
|
|
|
|
}).ToList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var activitiesSubList = _serviceWorkFlowActivitiesSubRelationRepository.AsQueryable()
|
|
|
|
|
.LeftJoin<ServiceWorkFlowActivitiesInfo>((rela, act) =>
|
|
|
|
|
rela.SUB_SERVICE_ACTIVITIES_ID == act.PK_ID && rela.SERVICE_WORKFLOW_ID == pkId)
|
|
|
|
|
.LeftJoin<StatusSkuBaseInfo>((rela, act, sku) => act.STATUS_SKU_ID == sku.PK_ID)
|
|
|
|
|
.Select((rela, act, sku) =>
|
|
|
|
|
new { Act = act, Sku = sku, SortNo = rela.SORT_NO, ParentId = rela.SERVICE_ACTIVITIES_ID })
|
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
|
|
if(activitiesSubList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
var subList = activitiesSubList
|
|
|
|
|
.GroupBy(a => a.ParentId)
|
|
|
|
|
.Select(a => {
|
|
|
|
|
var actModel = a.Act.Adapt<ServiceWorkFlowActivitiesShowDto>();
|
|
|
|
|
var currArg = a.ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return new { Key = a.Key, SubList = currArg.OrderBy(b=>b.SortNo)
|
|
|
|
|
.Select(b => {
|
|
|
|
|
var actModel = b.Act.Adapt<ServiceWorkFlowActivitiesSubShowDto>();
|
|
|
|
|
|
|
|
|
|
actModel.SortNo = b.SortNo;
|
|
|
|
|
actModel.statusSkuBase = b.Sku.Adapt<StatusSkuBaseDto>();
|
|
|
|
|
|
|
|
|
|
return actModel;
|
|
|
|
|
}).ToList() };
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
showModel.StatusSkuList.GroupJoin(subList, l => l.PKId, r => r.Key, (l,
|
|
|
|
|
r) => {
|
|
|
|
|
var currArg = r.ToList();
|
|
|
|
|
|
|
|
|
|
if (currArg.Count == 0)
|
|
|
|
|
return l;
|
|
|
|
|
|
|
|
|
|
l.SubList = currArg.FirstOrDefault().SubList.ToList();
|
|
|
|
|
|
|
|
|
|
actModel.statusSkuBase = a.Sku.Adapt<StatusSkuBaseDto>();
|
|
|
|
|
return l;
|
|
|
|
|
|
|
|
|
|
return actModel;
|
|
|
|
|
}).ToList();
|
|
|
|
|
}).ToList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return showModel;
|
|
|
|
|