diff --git a/Myshipping.Application/Entity/TrackingSystem/ServiceWorkFlowRunActivitiesInfo.cs b/Myshipping.Application/Entity/TrackingSystem/ServiceWorkFlowRunActivitiesInfo.cs index fe8e0ddd..2ab9609b 100644 --- a/Myshipping.Application/Entity/TrackingSystem/ServiceWorkFlowRunActivitiesInfo.cs +++ b/Myshipping.Application/Entity/TrackingSystem/ServiceWorkFlowRunActivitiesInfo.cs @@ -17,12 +17,6 @@ namespace Myshipping.Application.Entity [Description("服务流程运行活动表")] public class ServiceWorkFlowRunActivitiesInfo : TrackingSystemDbEntity { - public ServiceWorkFlowRunActivitiesInfo() - { - PK_ID = IDGen.NextID().ToString(); - - CreatedTime = DateTime.Now; - } /// /// 运行主键 @@ -59,6 +53,11 @@ namespace Myshipping.Application.Entity /// public Nullable ACT_DATE { get; set; } + /// + /// 活动备注 + /// + public string ACT_REMARK { get; set; } + /// /// 下一个活动ID /// diff --git a/Myshipping.Application/Service/BookingOrder/BookingValueAddedService.cs b/Myshipping.Application/Service/BookingOrder/BookingValueAddedService.cs index fb3f44c9..fc62ab4b 100644 --- a/Myshipping.Application/Service/BookingOrder/BookingValueAddedService.cs +++ b/Myshipping.Application/Service/BookingOrder/BookingValueAddedService.cs @@ -2281,7 +2281,8 @@ namespace Myshipping.Application { StatusCode = a.StatusCode, StatusDate = a.SetActDate, - StatusVal = a.SetActVal + StatusVal = a.SetActVal, + Remark = a.ActRemark }).ToList() } }; @@ -2372,7 +2373,8 @@ namespace Myshipping.Application { StatusCode = a.StatusCode, StatusDate = a.SetActDate, - StatusVal = a.SetActVal + StatusVal = a.SetActVal, + Remark = a.ActRemark }).ToList() } }; diff --git a/Myshipping.Application/Service/BookingOrder/Dto/ModifyServiceProjectDto.cs b/Myshipping.Application/Service/BookingOrder/Dto/ModifyServiceProjectDto.cs index 243a538b..3cc49b5e 100644 --- a/Myshipping.Application/Service/BookingOrder/Dto/ModifyServiceProjectDto.cs +++ b/Myshipping.Application/Service/BookingOrder/Dto/ModifyServiceProjectDto.cs @@ -54,5 +54,10 @@ namespace Myshipping.Application /// 人工设定状态值(可传箱使天数) /// public string SetActVal { get; set; } + + /// + /// 状态备注 + /// + public string ActRemark { get; set; } } } diff --git a/Myshipping.Application/Service/TrackingSystem/Dtos/ServiceProjectWithStatusDto.cs b/Myshipping.Application/Service/TrackingSystem/Dtos/ServiceProjectWithStatusDto.cs index 80025a59..74edb012 100644 --- a/Myshipping.Application/Service/TrackingSystem/Dtos/ServiceProjectWithStatusDto.cs +++ b/Myshipping.Application/Service/TrackingSystem/Dtos/ServiceProjectWithStatusDto.cs @@ -149,6 +149,10 @@ namespace Myshipping.Application /// public string ActVal { get; set; } + /// + /// 备注 + /// + public string ActRemark { get; set; } /// /// 子状态列表 diff --git a/Myshipping.Application/Service/TrackingSystem/Dtos/ServiceWorkFlowActivitiesRunDto.cs b/Myshipping.Application/Service/TrackingSystem/Dtos/ServiceWorkFlowActivitiesRunDto.cs index f3b169bf..68e7817b 100644 --- a/Myshipping.Application/Service/TrackingSystem/Dtos/ServiceWorkFlowActivitiesRunDto.cs +++ b/Myshipping.Application/Service/TrackingSystem/Dtos/ServiceWorkFlowActivitiesRunDto.cs @@ -76,6 +76,11 @@ namespace Myshipping.Application /// public string SourceType { get; set; } + /// + /// 备注 + /// + public string ActRemark { get; set; } + /// /// 子活动列表 /// @@ -148,5 +153,10 @@ namespace Myshipping.Application /// 来源类型 AUTO-自动 MANUAL-人工 /// public string SourceType { get; set; } + + /// + /// 备注 + /// + public string ActRemark { get; set; } } } diff --git a/Myshipping.Application/Service/TrackingSystem/Dtos/TrackingMessageInfo.cs b/Myshipping.Application/Service/TrackingSystem/Dtos/TrackingMessageInfo.cs index 22351c2e..86e1129e 100644 --- a/Myshipping.Application/Service/TrackingSystem/Dtos/TrackingMessageInfo.cs +++ b/Myshipping.Application/Service/TrackingSystem/Dtos/TrackingMessageInfo.cs @@ -208,6 +208,11 @@ namespace Myshipping.Application /// 状态产生值 /// public string StatusVal { get; set; } + + /// + /// 状态备注 + /// + public string Remark { get; set; } } /// diff --git a/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowManageService.cs b/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowManageService.cs index 16c28bf6..14b70f1a 100644 --- a/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowManageService.cs +++ b/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowManageService.cs @@ -327,7 +327,7 @@ namespace Myshipping.Application await _serviceWorkFlowRunInfoRepository.InsertAsync(serviceWorkFlowRunInfo); //获取状态最大数 - int endNum = rt.StatusList.Max(sku => sku.SortNo); + int endNum = rt.StatusList.Max(sku => sku.ActSortNo); string lastActId = string.Empty; @@ -337,9 +337,9 @@ namespace Myshipping.Application { PK_ID = IDGen.NextID().ToString(), RUN_ID = serviceWorkFlowRunInfo.PK_ID, - EXEC_SORT_NO = sku.SortNo, - IS_START = sku.SortNo == 1 ? 1 : 0, - IS_END = sku.SortNo == endNum ? 1 : 0, + EXEC_SORT_NO = sku.ActSortNo, + IS_START = sku.ActSortNo == 1 ? 1 : 0, + IS_END = sku.ActSortNo == endNum ? 1 : 0, ACT_ID = sku.ActPKId, STATUS_SKU_CODE = sku.StatusSKUCode, STATUS_SKU_ID = sku.SkuPKId, @@ -354,7 +354,7 @@ namespace Myshipping.Application TenantId = info.Main.OperTenantId, TenantName = info.Main.OperTenantName, IsDeleted = false, - SOURCE_TYPE = info.Main.SourceType.ToString(), + SOURCE_TYPE = info.Main.SourceType.ToString() }; if (st.StatusCode.Equals(sku.StatusSKUCode,StringComparison.OrdinalIgnoreCase)) @@ -371,6 +371,7 @@ namespace Myshipping.Application } activitiesRunInfo.ACT_VAL = st.StatusVal; + activitiesRunInfo.ACT_REMARK = st.Remark; } //写入run活动表 @@ -386,9 +387,9 @@ namespace Myshipping.Application { PK_ID = IDGen.NextID().ToString(), RUN_ID = serviceWorkFlowRunInfo.PK_ID, - EXEC_SORT_NO = sub.SortNo, - IS_START = sub.SortNo == 1 ? 1 : 0, - IS_END = sub.SortNo == endNum ? 1 : 0, + EXEC_SORT_NO = sub.ActSortNo, + IS_START = sub.ActSortNo == 1 ? 1 : 0, + IS_END = sub.ActSortNo == endNum ? 1 : 0, ACT_ID = sub.ActPKId, STATUS_SKU_CODE = sub.StatusSKUCode, STATUS_SKU_ID = sub.SkuPKId, @@ -421,6 +422,7 @@ namespace Myshipping.Application } activitiesSubRunInfo.ACT_VAL = st.StatusVal; + activitiesSubRunInfo.ACT_REMARK = st.Remark; } if (!string.IsNullOrWhiteSpace(lastSubActId)) @@ -437,7 +439,8 @@ namespace Myshipping.Application } else { - if (runList.Any(b => b.Detail == null)) + if (runList.Any(b + => b.Detail == null || (b.Detail != null && string.IsNullOrWhiteSpace(b.Detail.PK_ID)))) { var runMain = runList.FirstOrDefault().Main; //需要补充活动表明细 @@ -465,7 +468,7 @@ namespace Myshipping.Application //批量写入活动表 #region 批量写入活动表 //获取状态最大数 - int endNum = rt.StatusList.Max(sku => sku.SortNo); + int endNum = rt.StatusList.Max(sku => sku.ActSortNo); string lastActId = string.Empty; @@ -475,9 +478,9 @@ namespace Myshipping.Application { PK_ID = IDGen.NextID().ToString(), RUN_ID = runEntity.PK_ID, - EXEC_SORT_NO = sku.SortNo, - IS_START = sku.SortNo == 1 ? 1 : 0, - IS_END = sku.SortNo == endNum ? 1 : 0, + EXEC_SORT_NO = sku.ActSortNo, + IS_START = sku.ActSortNo == 1 ? 1 : 0, + IS_END = sku.ActSortNo == endNum ? 1 : 0, ACT_ID = sku.ActPKId, STATUS_SKU_CODE = sku.StatusSKUCode, STATUS_SKU_ID = sku.SkuPKId, @@ -509,6 +512,7 @@ namespace Myshipping.Application } activitiesRunInfo.ACT_VAL = st.StatusVal; + activitiesRunInfo.ACT_REMARK = st.Remark; } //写入run活动表 @@ -524,9 +528,9 @@ namespace Myshipping.Application { PK_ID = IDGen.NextID().ToString(), RUN_ID = runEntity.PK_ID, - EXEC_SORT_NO = sub.SortNo, - IS_START = sub.SortNo == 1 ? 1 : 0, - IS_END = sub.SortNo == endNum ? 1 : 0, + EXEC_SORT_NO = sub.ActSortNo, + IS_START = sub.ActSortNo == 1 ? 1 : 0, + IS_END = sub.ActSortNo == endNum ? 1 : 0, ACT_ID = sub.ActPKId, STATUS_SKU_CODE = sub.StatusSKUCode, STATUS_SKU_ID = sub.SkuPKId, @@ -559,6 +563,7 @@ namespace Myshipping.Application } activitiesSubRunInfo.ACT_VAL = st.StatusVal; + activitiesSubRunInfo.ACT_REMARK = st.Remark; } if (!string.IsNullOrWhiteSpace(lastSubActId)) @@ -576,7 +581,90 @@ namespace Myshipping.Application else { //只需要更新完成标记和完成时间 + rt.StatusList.ForEach(async sku => + { + var currRunDetail = runList.FirstOrDefault(p => + p.Detail.STATUS_SKU_CODE.Equals(sku.StatusSKUCode)).Detail; + + var activitiesRunInfo = _serviceWorkFlowRunActivitiesInfoRepository.AsQueryable() + .First(p=>p.PK_ID == currRunDetail.PK_ID); + + if (st.StatusCode.Equals(sku.StatusSKUCode, StringComparison.OrdinalIgnoreCase)) + { + activitiesRunInfo.IS_YIELD = 1; + + if (st.StatusDate.HasValue) + { + activitiesRunInfo.ACT_DATE = st.StatusDate.Value; + } + else + { + activitiesRunInfo.ACT_DATE = nowDate; + } + + activitiesRunInfo.ACT_VAL = st.StatusVal; + activitiesRunInfo.ACT_REMARK = st.Remark; + + activitiesRunInfo.UpdatedTime = nowDate; + activitiesRunInfo.CreatedUserId = long.Parse(info.Main.OperUserId); + activitiesRunInfo.CreatedUserName = info.Main.OperUserName; + await _serviceWorkFlowRunActivitiesInfoRepository.AsUpdateable(activitiesRunInfo) + .UpdateColumns(it => new + { + it.ACT_DATE, + it.IS_YIELD, + it.ACT_REMARK, + it.UpdatedTime, + it.UpdatedUserId, + it.UpdatedUserName + }).ExecuteCommandAsync(); + } + + if (sku.SubStatusList != null && sku.SubStatusList.Count > 0) + { + sku.SubStatusList.ForEach(async sub => { + + var currRunDetailSub = runList.FirstOrDefault(p => + p.Detail.STATUS_SKU_CODE.Equals(sub.StatusSKUCode)).Detail; + + var activitiesSubRunInfo = _serviceWorkFlowRunActivitiesInfoRepository.AsQueryable() + .First(p=> currRunDetailSub.STATUS_SKU_CODE.Equals(sub.StatusSKUCode)); + + if (st.StatusCode.Equals(sub.StatusSKUCode, StringComparison.OrdinalIgnoreCase)) + { + activitiesSubRunInfo.IS_YIELD = 1; + + if (st.StatusDate.HasValue) + { + activitiesSubRunInfo.ACT_DATE = st.StatusDate.Value; + } + else + { + activitiesSubRunInfo.ACT_DATE = nowDate; + } + + activitiesSubRunInfo.ACT_VAL = st.StatusVal; + activitiesSubRunInfo.ACT_REMARK = st.Remark; + + activitiesSubRunInfo.UpdatedTime = nowDate; + activitiesSubRunInfo.CreatedUserId = long.Parse(info.Main.OperUserId); + activitiesSubRunInfo.CreatedUserName = info.Main.OperUserName; + + await _serviceWorkFlowRunActivitiesInfoRepository.AsUpdateable(activitiesSubRunInfo) + .UpdateColumns(it => new + { + it.ACT_DATE, + it.IS_YIELD, + it.ACT_REMARK, + it.UpdatedTime, + it.UpdatedUserId, + it.UpdatedUserName + }).ExecuteCommandAsync(); + } + }); + } + }); } } }); @@ -639,12 +727,13 @@ namespace Myshipping.Application .LeftJoin((m, s) => m.PK_ID == s.RUN_ID) .LeftJoin((m, s, rela) => m.SERVICE_WF_ID == rela.SERVICE_WORKFLOW_ID && m.RELEASE_VERSION == rela.WF_VERSION) - .LeftJoin((m, s, rela, p) => + .InnerJoin((m, s, rela, p) => rela.SERVICE_PROJECT_ID == p.PK_ID) .Where((m, s, rela, p) => m.BUSI_SYSTEM_CODE == info.Main.BusiSystemCode && m.BUSI_ID == info.Main.BusiId && (info.Main.ServiceProjectCodeList == null || info.Main.ServiceProjectCodeList.Contains(p.SERVICE_PROJECT_CODE))) - .Select((m, s) => new { Run = m, Sub = s }).ToList(); + .Select((m, s,rela,p) => + new { Run = m, Sub = s }).ToList(); var resultList = runList.GroupBy(a => a.Run.PK_ID) .Select(a => { @@ -662,7 +751,8 @@ namespace Myshipping.Application showModel.ActDate = runInfo.ACT_DATE; showModel.WFPKId = runInfo.SERVICE_WF_ID; - showModel.ActivitiesList = currList.Where(t => t.Sub.IS_SUB == 0) + showModel.ActivitiesList = currList.Where(t => + !string.IsNullOrWhiteSpace(t.Sub.PK_ID) && t.Sub.IS_SUB == 0) .Select(t => { var runModel = new ServiceWorkFlowActivitiesRunDto @@ -679,14 +769,16 @@ namespace Myshipping.Application ShowName = t.Sub.SHOW_NAME, SourceType = t.Sub.SOURCE_TYPE, StatusSKUCode = t.Sub.STATUS_SKU_CODE, - StatusSKUId = t.Sub.STATUS_SKU_ID + StatusSKUId = t.Sub.STATUS_SKU_ID, + ActRemark = t.Sub.ACT_REMARK, }; return runModel; }).ToList(); var subList = - currList.Where(t => t.Sub.IS_SUB == 1) + currList.Where(t => + !string.IsNullOrWhiteSpace(t.Sub.PK_ID) && t.Sub.IS_SUB == 1) .Select(t => t.Sub).ToList(); showModel.ActivitiesList = showModel.ActivitiesList.GroupJoin(subList, @@ -713,7 +805,8 @@ namespace Myshipping.Application ShowName = x.SHOW_NAME, SourceType = x.SOURCE_TYPE, StatusSKUCode = x.STATUS_SKU_CODE, - StatusSKUId = x.STATUS_SKU_ID + StatusSKUId = x.STATUS_SKU_ID, + ActRemark = x.ACT_REMARK }; return subModel; @@ -1526,8 +1619,9 @@ namespace Myshipping.Application ActPKId = b.ActPKId, ActSortNo = b.ActSortNo, ShowName = b.ShowName, - IsYield = false - + IsYield = false, + StatusSKUCode = b.StatusSKUCode, + ActRemark = b.ActRemark }); if(b.SubStatusList != null && b.SubStatusList.Count > 0) @@ -1537,8 +1631,9 @@ namespace Myshipping.Application ActPKId = c.ActPKId, ActSortNo = c.ActSortNo, ShowName = c.ShowName, - IsYield = false - + IsYield = false, + StatusSKUCode = b.StatusSKUCode, + ActRemark = b.ActRemark }).ToList()); } }); @@ -1552,7 +1647,9 @@ namespace Myshipping.Application ShowName = b.ShowName, IsYield = b.IsYield == 1 ? true : false, ActDate = b.ActDate, - ActVal = b.ActVal + ActVal = b.ActVal, + StatusSKUCode = b.StatusSKUCode, + ActRemark = b.ActRemark }).ToList(); } }