Browse Source

Merge branch 'release' of http://git.12345lm.cn/Fengwo/hotline into release

qinchaoyue 6 tháng trước cách đây
mục cha
commit
14c8c40aaf

+ 166 - 102
src/Hotline.Api/Controllers/Bigscreen/DataScreenController.cs

@@ -1,4 +1,5 @@
-using Hotline.KnowledgeBase;
+using Hotline.Configurations;
+using Hotline.KnowledgeBase;
 using Hotline.Orders;
 using Hotline.Repository.SqlSugar.Orders;
 using Hotline.Settings;
@@ -10,12 +11,13 @@ using Hotline.Share.Enums.Order;
 using MapsterMapper;
 using Microsoft.AspNetCore.Authorization;
 using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Options;
 using SqlSugar;
 using XF.Domain.Repository;
 
 namespace Hotline.Api.Controllers.Bigscreen
 {
-    public class DataScreenController: BaseController
+    public class DataScreenController : BaseController
     {
         private readonly IOrderRepository _orderRepository;
         private readonly IRepository<OrderDelay> _orderDelayRepository;
@@ -25,8 +27,12 @@ namespace Hotline.Api.Controllers.Bigscreen
         private readonly IMapper _mapper;
         private readonly IRepository<OrderVisitDetail> _orderVisitDetailRepository;
         private readonly IRepository<SystemArea> _systemAreaRepository;
+        private readonly IOptionsSnapshot<AppConfiguration> _appOptions;
 
-        public DataScreenController(IOrderRepository orderRepository, IRepository<OrderVisit> orderVisitRepository, IRepository<OrderDelay> orderDelayRepository, IRepository<Knowledge> knowledgeRepository, IRepository<KnowledgePv> knowledgePvRepository,IMapper  mapper,IRepository<OrderVisitDetail> orderVisitDetailRepository, IRepository<SystemArea> systemAreaRepository)
+        public DataScreenController(IOrderRepository orderRepository, IRepository<OrderVisit> orderVisitRepository,
+            IRepository<OrderDelay> orderDelayRepository, IRepository<Knowledge> knowledgeRepository, IRepository<KnowledgePv> knowledgePvRepository,
+            IMapper mapper, IRepository<OrderVisitDetail> orderVisitDetailRepository, IRepository<SystemArea> systemAreaRepository,
+            IOptionsSnapshot<AppConfiguration> appOptions)
         {
             _orderRepository = orderRepository;
             _orderVisitRepository = orderVisitRepository;
@@ -36,6 +42,7 @@ namespace Hotline.Api.Controllers.Bigscreen
             _mapper = mapper;
             _orderVisitDetailRepository = orderVisitDetailRepository;
             _systemAreaRepository = systemAreaRepository;
+            _appOptions = appOptions;
         }
 
         /// <summary>
@@ -44,15 +51,18 @@ namespace Hotline.Api.Controllers.Bigscreen
         /// <returns></returns>
         [AllowAnonymous]
         [HttpGet("order-statistics")]
-        public async Task<OrderStatisticsDto> OrderStatistics(DateTime StartTime,DateTime EndTime)
+        public async Task<OrderStatisticsDto> OrderStatistics(DateTime StartTime, DateTime EndTime)
         {
             EndTime = EndTime.AddDays(1).AddSeconds(-1);
             var dto = new OrderStatisticsDto();
 
             #region 办结工单
-            dto.CompletionCount =await _orderRepository.Queryable(false, false, false).Where(x => x.StartTime >= StartTime && x.StartTime <= EndTime && x.Status>= EOrderStatus.Filed).CountAsync();
-            int CompletionSum = await _orderRepository.Queryable(false, false, false).Where(x => x.StartTime >= StartTime && x.StartTime <= EndTime && x.Status >= EOrderStatus.Handling).CountAsync();
-            if (CompletionSum==0)
+
+            dto.CompletionCount = await _orderRepository.Queryable(false, false, false)
+                .Where(x => x.StartTime >= StartTime && x.StartTime <= EndTime && x.Status >= EOrderStatus.Filed).CountAsync();
+            int CompletionSum = await _orderRepository.Queryable(false, false, false)
+                .Where(x => x.StartTime >= StartTime && x.StartTime <= EndTime && x.Status >= EOrderStatus.Handling).CountAsync();
+            if (CompletionSum == 0)
             {
                 dto.CompletionRate = 0;
             }
@@ -60,11 +70,15 @@ namespace Hotline.Api.Controllers.Bigscreen
             {
                 dto.CompletionRate = Math.Round((dto.CompletionCount / (double)CompletionSum) * 100, 2);
             }
+
             #endregion
 
             #region 待受理工单
-            dto.HaveToAcceptCount =await _orderRepository.Queryable(false, false, false).Where(x => x.CreationTime > StartTime && x.CreationTime <= EndTime && x.Status == EOrderStatus.WaitForAccept).CountAsync();
-            int HaveToAcceptSum = await _orderRepository.Queryable(false, false, false).Where(x => x.CreationTime >= StartTime && x.CreationTime <= EndTime).CountAsync();
+
+            dto.HaveToAcceptCount = await _orderRepository.Queryable(false, false, false)
+                .Where(x => x.CreationTime > StartTime && x.CreationTime <= EndTime && x.Status == EOrderStatus.WaitForAccept).CountAsync();
+            int HaveToAcceptSum = await _orderRepository.Queryable(false, false, false)
+                .Where(x => x.CreationTime >= StartTime && x.CreationTime <= EndTime).CountAsync();
             if (HaveToAcceptSum == 0)
             {
                 dto.HaveToAcceptRate = 0;
@@ -73,11 +87,14 @@ namespace Hotline.Api.Controllers.Bigscreen
             {
                 dto.HaveToAcceptRate = Math.Round((dto.HaveToAcceptCount / (double)HaveToAcceptSum) * 100, 2);
             }
+
             #endregion
 
             #region 超期工单
-            dto.OverTimeCount = await _orderRepository.Queryable(false, false, false).Where(x => x.StartTime >= StartTime && x.StartTime <= EndTime && x.ExpiredStatus == EExpiredStatus.Expired).CountAsync();
-            if (CompletionSum==0)
+
+            dto.OverTimeCount = await _orderRepository.Queryable(false, false, false)
+                .Where(x => x.StartTime >= StartTime && x.StartTime <= EndTime && x.ExpiredStatus == EExpiredStatus.Expired).CountAsync();
+            if (CompletionSum == 0)
             {
                 dto.OverTimeRate = 0;
             }
@@ -85,11 +102,14 @@ namespace Hotline.Api.Controllers.Bigscreen
             {
                 dto.OverTimeRate = Math.Round((dto.OverTimeCount / (double)CompletionSum) * 100, 2);
             }
+
             #endregion
 
             #region 延期工单
-            dto.DelayCount = await _orderDelayRepository.Queryable().Where(x => x.ApplyDelayTime >= StartTime && x.ApplyDelayTime <= EndTime && x.DelayState == EDelayState.Pass).CountAsync();
-            if (CompletionSum==0)
+
+            dto.DelayCount = await _orderDelayRepository.Queryable()
+                .Where(x => x.ApplyDelayTime >= StartTime && x.ApplyDelayTime <= EndTime && x.DelayState == EDelayState.Pass).CountAsync();
+            if (CompletionSum == 0)
             {
                 dto.DelayRate = 0;
             }
@@ -101,9 +121,13 @@ namespace Hotline.Api.Controllers.Bigscreen
             #endregion
 
             #region 满意工单
-            dto.SatisfiedCount =await _orderVisitRepository.Queryable().Where(x => x.VisitTime >= StartTime && x.VisitTime <= EndTime && x.VisitState == EVisitState.Visited && SqlFunc.JsonField(x.NowEvaluate, "Key") != "1" && SqlFunc.JsonField(x.NowEvaluate,"Key")!="2" ).CountAsync();
-            int SatisfiedSum = await _orderVisitRepository.Queryable().Where(x => x.VisitTime >= StartTime && x.VisitTime <= EndTime && x.VisitState == EVisitState.Visited).CountAsync();
-            if (SatisfiedSum==0)
+
+            dto.SatisfiedCount = await _orderVisitRepository.Queryable().Where(x =>
+                x.VisitTime >= StartTime && x.VisitTime <= EndTime && x.VisitState == EVisitState.Visited &&
+                SqlFunc.JsonField(x.NowEvaluate, "Key") != "1" && SqlFunc.JsonField(x.NowEvaluate, "Key") != "2").CountAsync();
+            int SatisfiedSum = await _orderVisitRepository.Queryable()
+                .Where(x => x.VisitTime >= StartTime && x.VisitTime <= EndTime && x.VisitState == EVisitState.Visited).CountAsync();
+            if (SatisfiedSum == 0)
             {
                 dto.SatisfiedRate = 0;
             }
@@ -111,12 +135,16 @@ namespace Hotline.Api.Controllers.Bigscreen
             {
                 dto.SatisfiedRate = Math.Round((dto.SatisfiedCount / (double)SatisfiedSum) * 100, 2);
             }
+
             #endregion
 
             #region 省工单量
 
-            dto.ProvinceOrderCount =await _orderRepository.Queryable(false, false, false).Where(x => x.StartTime >= StartTime && x.StartTime <= EndTime && x.IsProvince).CountAsync();
-            dto.ProvinceOrderCompletionCount = await _orderRepository.Queryable(false, false, false).Where(x => x.StartTime >= StartTime && x.StartTime <= EndTime && x.IsProvince && x.Status >= EOrderStatus.Filed).CountAsync();
+            dto.ProvinceOrderCount = await _orderRepository.Queryable(false, false, false)
+                .Where(x => x.StartTime >= StartTime && x.StartTime <= EndTime && x.IsProvince).CountAsync();
+            dto.ProvinceOrderCompletionCount = await _orderRepository.Queryable(false, false, false)
+                .Where(x => x.StartTime >= StartTime && x.StartTime <= EndTime && x.IsProvince && x.Status >= EOrderStatus.Filed).CountAsync();
+
             #endregion
 
             return dto;
@@ -131,10 +159,14 @@ namespace Hotline.Api.Controllers.Bigscreen
         public async Task<KnowledgeStatisticsDto> KnowledgeStatistics()
         {
             var dto = new KnowledgeStatisticsDto();
-            dto.KnowledgeCount = await _knowledgeRepository.Queryable().Where(x => x.Status == EKnowledgeStatus.OnShelf).CountAsync();//总数
-            dto.TodayAddCount = await _knowledgeRepository.Queryable().Where(x => x.Renewaln==false && x.Status == EKnowledgeStatus.OnShelf && x.OnShelfTime.Value.Date== DateTime.Now.Date).CountAsync();//今日新增
-            dto.ThisMonthModifyCount = await _knowledgeRepository.Queryable().Where(x => x.Renewaln == true && x.Status == EKnowledgeStatus.OnShelf && x.OnShelfTime.Value.Year
-            == DateTime.Now.Year && x.OnShelfTime.Value.Month == DateTime.Now.Month).CountAsync();//本月修改
+            dto.KnowledgeCount = await _knowledgeRepository.Queryable().Where(x => x.Status == EKnowledgeStatus.OnShelf).CountAsync(); //总数
+            dto.TodayAddCount = await _knowledgeRepository.Queryable().Where(x =>
+                x.Renewaln == false && x.Status == EKnowledgeStatus.OnShelf && x.OnShelfTime.Value.Date == DateTime.Now.Date).CountAsync(); //今日新增
+            dto.ThisMonthModifyCount = await _knowledgeRepository.Queryable().Where(x => x.Renewaln == true && x.Status == EKnowledgeStatus.OnShelf &&
+                                                                                         x.OnShelfTime.Value.Year
+                                                                                         == DateTime.Now.Year &&
+                                                                                         x.OnShelfTime.Value.Month == DateTime.Now.Month)
+                .CountAsync(); //本月修改
             dto.TodayReadCount = await _knowledgePvRepository.Queryable().Where(x => x.CreationTime.Date == DateTime.Now.Date).CountAsync();
             return dto;
         }
@@ -147,18 +179,19 @@ namespace Hotline.Api.Controllers.Bigscreen
         /// <returns></returns>
         [AllowAnonymous]
         [HttpGet("ordertype-statistics")]
-        public async Task<List<OrderTypeHandleStatisticsDto>> OrderTypeHandleStatistics(DateTime StartTime,DateTime EndTime)
+        public async Task<List<OrderTypeHandleStatisticsDto>> OrderTypeHandleStatistics(DateTime StartTime, DateTime EndTime)
         {
             EndTime = EndTime.AddDays(1).AddSeconds(-1);
-            var list =await _orderRepository.Queryable(false, false, false).Where(x => x.StartTime >= StartTime && x.StartTime <= EndTime && x.Status > EOrderStatus.Handling && !string.IsNullOrEmpty(x.AcceptType))
-                .GroupBy(x=>x.AcceptType)
+            var list = await _orderRepository.Queryable(false, false, false).Where(x =>
+                    x.StartTime >= StartTime && x.StartTime <= EndTime && x.Status > EOrderStatus.Handling && !string.IsNullOrEmpty(x.AcceptType))
+                .GroupBy(x => x.AcceptType)
                 .Select(x => new OrderTypeHandleStatisticsDto
-                { 
-                     AcceptType = x.AcceptType,
-                     SumCount = SqlFunc.AggregateCount(x.Id),
-                     HandlingCount = SqlFunc.AggregateSum(SqlFunc.IIF(x.Status>= EOrderStatus.Handling && x.Status < EOrderStatus.Filed,1,0)),
-                     FiledCount = SqlFunc.AggregateSum(SqlFunc.IIF(x.Status>= EOrderStatus.Filed,1,0)),
-                     OverTimeCount = SqlFunc.AggregateSum(SqlFunc.IIF(x.ExpiredStatus == EExpiredStatus.Expired,1,0))
+                {
+                    AcceptType = x.AcceptType,
+                    SumCount = SqlFunc.AggregateCount(x.Id),
+                    HandlingCount = SqlFunc.AggregateSum(SqlFunc.IIF(x.Status >= EOrderStatus.Handling && x.Status < EOrderStatus.Filed, 1, 0)),
+                    FiledCount = SqlFunc.AggregateSum(SqlFunc.IIF(x.Status >= EOrderStatus.Filed, 1, 0)),
+                    OverTimeCount = SqlFunc.AggregateSum(SqlFunc.IIF(x.ExpiredStatus == EExpiredStatus.Expired, 1, 0))
                 }).ToListAsync();
             return list;
         }
@@ -171,8 +204,9 @@ namespace Hotline.Api.Controllers.Bigscreen
         [AllowAnonymous]
         public async Task<object> GetSystemAreaAsync()
         {
+            var areaCode = _appOptions.Value.GetDefaultAppScopeConfiguration().AreaCode;
             return await _systemAreaRepository.Queryable()
-                .Where(p => p.Id == "511500" || p.ParentId == "511500")
+                .Where(p => p.Id == areaCode || p.ParentId == areaCode)
                 .Select(p => new
                 {
                     p.AreaName,
@@ -191,23 +225,25 @@ namespace Hotline.Api.Controllers.Bigscreen
         /// <returns></returns>
         [AllowAnonymous]
         [HttpGet("earlywarning-statistics")]
-        public async Task<List<EarlyWarningHotsPotsStatisticsDto>> EarlyWarningHotsPotsStatistics(DateTime StartTime, DateTime EndTime,string AreaCode)
+        public async Task<List<EarlyWarningHotsPotsStatisticsDto>> EarlyWarningHotsPotsStatistics(DateTime StartTime, DateTime EndTime,
+            string AreaCode)
         {
             EndTime = EndTime.AddDays(1).AddSeconds(-1);
-            if (AreaCode.Length==6 && AreaCode.IndexOf("00") == 4)
+            if (AreaCode.Length == 6 && AreaCode.IndexOf("00") == 4)
             {
                 AreaCode = AreaCode.Remove(4);
             }
-             var list = await _orderRepository.Queryable(false, false, false)
+
+            var list = await _orderRepository.Queryable(false, false, false)
                 .Where(x => x.StartTime >= StartTime && x.StartTime <= EndTime && x.AreaCode.StartsWith(AreaCode) && !x.HotspotId.StartsWith("18"))
-                .GroupBy(x => new { x.HotspotId, x.HotspotName,x.HotspotSpliceName })
+                .GroupBy(x => new { x.HotspotId, x.HotspotName, x.HotspotSpliceName })
                 .Select(x => new EarlyWarningHotsPotsStatisticsDto()
                 {
-                     HotspotId = x.HotspotId,
-                     HotspotName = x.HotspotName,
-                     HotspotSpliceName = x.HotspotSpliceName,
-                     SumCount = SqlFunc.AggregateCount(x.Id)
-                }).OrderByDescending(x=>x.SumCount).Take(5).ToListAsync();
+                    HotspotId = x.HotspotId,
+                    HotspotName = x.HotspotName,
+                    HotspotSpliceName = x.HotspotSpliceName,
+                    SumCount = SqlFunc.AggregateCount(x.Id)
+                }).OrderByDescending(x => x.SumCount).Take(5).ToListAsync();
             return list;
         }
 
@@ -221,14 +257,16 @@ namespace Hotline.Api.Controllers.Bigscreen
         {
             var today = DateTime.Now;
             var dto = new OrderCountStatisticsDto();
+
             #region 当日工单量
 
-            dto.ToDayCount = await _orderRepository.Queryable(false,false,false).Where(x => x.StartTime.Value.Date == DateTime.Now.Date && x.Status > EOrderStatus.WaitForAccept).CountAsync();
+            dto.ToDayCount = await _orderRepository.Queryable(false, false, false)
+                .Where(x => x.StartTime.Value.Date == DateTime.Now.Date && x.Status > EOrderStatus.WaitForAccept).CountAsync();
             var beforToDayCount = await _orderRepository.Queryable(false, false, false)
                 //.Where(x => x.StartTime.Value.Date == today.AddDays(-1).Date && x.Status > EOrderStatus.WaitForAccept)
-                .Where(x=>x.StartTime.Value.Date == DateTime.Now.AddDays(-1).Date && x.Status > EOrderStatus.WaitForAccept)
+                .Where(x => x.StartTime.Value.Date == DateTime.Now.AddDays(-1).Date && x.Status > EOrderStatus.WaitForAccept)
                 .CountAsync();
-                
+
 
             if (beforToDayCount == 0)
             {
@@ -238,15 +276,19 @@ namespace Hotline.Api.Controllers.Bigscreen
             {
                 dto.ToDayQoQ = Math.Round(((dto.ToDayCount - beforToDayCount) / (double)beforToDayCount) * 100, 2);
             }
+
             #endregion
 
             #region 当月工单量
 
-            dto.ToMonthCount = await _orderRepository.Queryable(false, false, false).Where(x => x.StartTime.Value.ToString("yyyy-MM") == today.ToString("yyyy-MM") && x.Status > EOrderStatus.WaitForAccept).CountAsync();
+            dto.ToMonthCount = await _orderRepository.Queryable(false, false, false).Where(x =>
+                x.StartTime.Value.ToString("yyyy-MM") == today.ToString("yyyy-MM") && x.Status > EOrderStatus.WaitForAccept).CountAsync();
 
-            var beforToMonthCount = await _orderRepository.Queryable(false, false, false).Where(x => x.StartTime.Value.ToString("yyyy-MM") == today.AddMonths(-1).ToString("yyyy-MM") && x.Status > EOrderStatus.WaitForAccept).CountAsync();
+            var beforToMonthCount = await _orderRepository.Queryable(false, false, false).Where(x =>
+                    x.StartTime.Value.ToString("yyyy-MM") == today.AddMonths(-1).ToString("yyyy-MM") && x.Status > EOrderStatus.WaitForAccept)
+                .CountAsync();
 
-            if (beforToMonthCount==0)
+            if (beforToMonthCount == 0)
             {
                 dto.ToMonthQoQ = 0;
             }
@@ -259,11 +301,13 @@ namespace Hotline.Api.Controllers.Bigscreen
 
             #region 当年工单量
 
-            dto.ToYearCount = await _orderRepository.Queryable(false, false, false).Where(x => x.StartTime.Value.ToString("yyyy") == today.ToString("yyyy") && x.Status > EOrderStatus.WaitForAccept).CountAsync();
+            dto.ToYearCount = await _orderRepository.Queryable(false, false, false)
+                .Where(x => x.StartTime.Value.ToString("yyyy") == today.ToString("yyyy") && x.Status > EOrderStatus.WaitForAccept).CountAsync();
 
-            var beforToYearCount = await _orderRepository.Queryable(false, false, false).Where(x => x.StartTime.Value.ToString("yyyy") == today.AddYears(-1).ToString("yyyy") && x.Status > EOrderStatus.WaitForAccept).CountAsync();
+            var beforToYearCount = await _orderRepository.Queryable(false, false, false).Where(x =>
+                x.StartTime.Value.ToString("yyyy") == today.AddYears(-1).ToString("yyyy") && x.Status > EOrderStatus.WaitForAccept).CountAsync();
 
-            if (beforToYearCount==0)
+            if (beforToYearCount == 0)
             {
                 dto.ToYearQoQ = 0;
             }
@@ -271,6 +315,7 @@ namespace Hotline.Api.Controllers.Bigscreen
             {
                 dto.ToYearQoQ = Math.Round(((dto.ToYearCount - beforToYearCount) / (double)beforToYearCount) * 100, 2);
             }
+
             #endregion
 
             return dto;
@@ -282,24 +327,26 @@ namespace Hotline.Api.Controllers.Bigscreen
         /// <returns></returns>
         [AllowAnonymous]
         [HttpGet("orderarea-accept-statistics")]
-        public async Task<List<OrderAreaAcceptStatisticsDto>> OrderAreaAcceptStatistics(DateTime StartTime,DateTime EndTime)
+        public async Task<List<OrderAreaAcceptStatisticsDto>> OrderAreaAcceptStatistics(DateTime StartTime, DateTime EndTime)
         {
             EndTime = EndTime.AddDays(1).AddSeconds(-1);
 
-            var list = await _orderRepository.Queryable(false, false, false).Where(x => x.StartTime>= StartTime && x.StartTime<= EndTime && x.Status > EOrderStatus.WaitForAccept)
-                .LeftJoin<SystemArea>((it,o)=> it.AreaCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")) == o.Id)
-                .GroupBy((it,o) => new {
+            var list = await _orderRepository.Queryable(false, false, false)
+                .Where(x => x.StartTime >= StartTime && x.StartTime <= EndTime && x.Status > EOrderStatus.WaitForAccept)
+                .LeftJoin<SystemArea>((it, o) => it.AreaCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")) == o.Id)
+                .GroupBy((it, o) => new
+                {
                     AreaCode = it.AreaCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")),
                     o.AreaName,
                 })
-                .Select((it,o) => new OrderAreaAcceptStatisticsDto()
+                .Select((it, o) => new OrderAreaAcceptStatisticsDto()
                 {
                     AreaCode = it.AreaCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")),
                     AreaName = o.AreaName,
                     AcceptedCount = SqlFunc.AggregateCount(it.AreaCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6"))),
-                    CompletionCount = SqlFunc.AggregateSum(SqlFunc.IIF(it.Status>= EOrderStatus.Filed,1,0))
+                    CompletionCount = SqlFunc.AggregateSum(SqlFunc.IIF(it.Status >= EOrderStatus.Filed, 1, 0))
                 }).MergeTable()
-                .Where(x=> x.AreaCode!= "519800" && x.AreaCode!= "519900").OrderByDescending(it=> it.AcceptedCount).ToListAsync();
+                .Where(x => x.AreaCode != "519800" && x.AreaCode != "519900").OrderByDescending(it => it.AcceptedCount).ToListAsync();
             return list;
         }
 
@@ -312,24 +359,27 @@ namespace Hotline.Api.Controllers.Bigscreen
         /// <returns></returns>
         [AllowAnonymous]
         [HttpGet("orderareaaccept-query")]
-        public async Task<List<OrderAreaAcceptQueryDto>> OrderAreaAcceptQuery(DateTime StartTime,DateTime EndTime)
+        public async Task<List<OrderAreaAcceptQueryDto>> OrderAreaAcceptQuery(DateTime StartTime, DateTime EndTime)
         {
             EndTime = EndTime.AddDays(1).AddSeconds(-1);
 
 
-            var areaList =await _systemAreaRepository.Queryable()
+            var areaList = await _systemAreaRepository.Queryable()
                 .Where(x => !x.Id.EndsWith("00"))
-                .GroupBy(x => new { 
+                .GroupBy(x => new
+                {
                     Id = x.Id.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")),
                 })
-                .Select(x => new {
+                .Select(x => new
+                {
                     Id = x.Id.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")),
                 })
                 .MergeTable()
-                .LeftJoin<SystemArea>((it,o)=> it.Id == o.Id)
-                .Select((it, o) => new {
+                .LeftJoin<SystemArea>((it, o) => it.Id == o.Id)
+                .Select((it, o) => new
+                {
                     Id = it.Id,
-                    Name=o.AreaName
+                    Name = o.AreaName
                 })
                 .ToListAsync();
 
@@ -342,13 +392,20 @@ namespace Hotline.Api.Controllers.Bigscreen
                 var dto = new OrderAreaAcceptQueryDto();
                 dto.AreaCode = item.Id;
                 dto.AreaName = item.Name;
-                dto.HandlingCount = await _orderRepository.Queryable(false, false, false).Where(x => x.AreaCode == item.Id && x.StartTime >= StartTime && x.StartTime <= EndTime && x.Status > EOrderStatus.WaitForAccept && x.Status < EOrderStatus.Filed).CountAsync();
+                dto.HandlingCount = await _orderRepository.Queryable(false, false, false).Where(x =>
+                    x.AreaCode == item.Id && x.StartTime >= StartTime && x.StartTime <= EndTime && x.Status > EOrderStatus.WaitForAccept &&
+                    x.Status < EOrderStatus.Filed).CountAsync();
 
-                dto.FiledCount = await _orderRepository.Queryable(false, false, false).Where(x => x.AreaCode == item.Id && x.StartTime >= StartTime && x.StartTime <= EndTime && x.Status >= EOrderStatus.Filed).CountAsync();
+                dto.FiledCount = await _orderRepository.Queryable(false, false, false).Where(x =>
+                    x.AreaCode == item.Id && x.StartTime >= StartTime && x.StartTime <= EndTime && x.Status >= EOrderStatus.Filed).CountAsync();
 
-                dto.OverTimeCount = await _orderRepository.Queryable(false, false, false).Where(x => x.AreaCode == item.Id && x.StartTime >= StartTime && x.StartTime <= EndTime && x.ExpiredStatus == EExpiredStatus.Expired).CountAsync();
+                dto.OverTimeCount = await _orderRepository.Queryable(false, false, false).Where(x =>
+                        x.AreaCode == item.Id && x.StartTime >= StartTime && x.StartTime <= EndTime && x.ExpiredStatus == EExpiredStatus.Expired)
+                    .CountAsync();
 
-                var hotsPot = await _orderRepository.Queryable(false, false, false).Where(x => x.AreaCode == item.Id && x.StartTime >= StartTime && x.StartTime <= EndTime && x.Status > EOrderStatus.WaitForAccept).GroupBy(x => new { x.HotspotId, x.HotspotName })
+                var hotsPot = await _orderRepository.Queryable(false, false, false)
+                    .Where(x => x.AreaCode == item.Id && x.StartTime >= StartTime && x.StartTime <= EndTime && x.Status > EOrderStatus.WaitForAccept)
+                    .GroupBy(x => new { x.HotspotId, x.HotspotName })
                     .Select(x => new
                     {
                         HotsPotName = x.HotspotName,
@@ -358,22 +415,24 @@ namespace Hotline.Api.Controllers.Bigscreen
                 dto.HotspotName = hotsPot?.HotsPotName;
 
                 #region 满意度
+
                 var SatisfiedCount = await _orderRepository.Queryable(false, false, false)
                     .LeftJoin<OrderVisit>((it, o) => it.Id == o.OrderId && o.VisitState == EVisitState.Visited)
                     .Where((it, o) => it.AreaCode == item.Id && o.VisitTime >= StartTime && o.VisitTime <= EndTime
-                    && SqlFunc.JsonField(o.NowEvaluate, "Key") != "1" && SqlFunc.JsonField(o.NowEvaluate, "Key") != "2")
+                                      && SqlFunc.JsonField(o.NowEvaluate, "Key") != "1" && SqlFunc.JsonField(o.NowEvaluate, "Key") != "2")
                     .CountAsync();
                 var VisitCount = await _orderRepository.Queryable(false, false, false)
                     .LeftJoin<OrderVisit>((it, o) => it.Id == o.OrderId && o.VisitState == EVisitState.Visited)
                     .Where((it, o) => it.AreaCode == item.Id && o.VisitTime >= StartTime && o.VisitTime <= EndTime)
                     .CountAsync();
 
-                if (SatisfiedCount!=0 && VisitCount!=0)
+                if (SatisfiedCount != 0 && VisitCount != 0)
                 {
                     dto.SatisfiedRate = Math.Round((SatisfiedCount / (double)VisitCount) * 100, 2);
                 }
 
                 #endregion
+
                 list.Add(dto);
 
                 #endregion
@@ -392,9 +451,9 @@ namespace Hotline.Api.Controllers.Bigscreen
         {
             var list = await _orderRepository
                 .Queryable(false, false, false)
-                .Where(x => x.Status > EOrderStatus.WaitForAccept  && x.StartTime.Value.Date == DateTime.Now.Date )
+                .Where(x => x.Status > EOrderStatus.WaitForAccept && x.StartTime.Value.Date == DateTime.Now.Date)
                 //.Where(x => x.Status > EOrderStatus.WaitForAccept && x.StartTime.Value.Date == DateTime.Parse("2024-03-14").Date)
-                .OrderByDescending(x=>x.StartTime)
+                .OrderByDescending(x => x.StartTime)
                 .Take(50)
                 .ToListAsync();
             return _mapper.Map<List<OrderDto>>(list);
@@ -406,7 +465,7 @@ namespace Hotline.Api.Controllers.Bigscreen
         /// <returns></returns>
         [AllowAnonymous]
         [HttpGet("highmatter-warning")]
-        public async Task<List<HighMatterWarningDto>> HighMatterWarning(DateTime StartTime,DateTime EndTime)
+        public async Task<List<HighMatterWarningDto>> HighMatterWarning(DateTime StartTime, DateTime EndTime)
         {
             //var endDate = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
             //var startDate = endDate.AddDays(-30).Date;
@@ -421,7 +480,7 @@ namespace Hotline.Api.Controllers.Bigscreen
 
             var list = await _orderRepository.Queryable(false, false, false)
                 .Where(x => x.CreationTime >= StartTime && x.CreationTime <= EndTime)
-                .Where(x=> filterTitle.Any(s=> x.Title.Contains(s)) == false)
+                .Where(x => filterTitle.Any(s => x.Title.Contains(s)) == false)
                 .LeftJoin<SystemArea>((it, o) => it.AreaCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")) == o.Id)
                 .GroupBy((it, o) => new
                 {
@@ -431,7 +490,7 @@ namespace Hotline.Api.Controllers.Bigscreen
                     AreaCode = it.AreaCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")),
                     o.AreaName,
                 })
-                .Having((it,o) => SqlFunc.AggregateCount(it.HotspotName)>=5)
+                .Having((it, o) => SqlFunc.AggregateCount(it.HotspotName) >= 5)
                 .Select((it, o) => new HighMatterWarningDto()
                 {
                     AreaName = o.AreaName,
@@ -442,8 +501,9 @@ namespace Hotline.Api.Controllers.Bigscreen
                 })
                 .MergeTable()
                 //.Where(x=>x.SumCount>=5)
-                .LeftJoin<Order>((x,d)=>x.Id==d.Id)
-                .Select((x,d)=>new HighMatterWarningDto() { 
+                .LeftJoin<Order>((x, d) => x.Id == d.Id)
+                .Select((x, d) => new HighMatterWarningDto()
+                {
                     AreaName = x.AreaName,
                     HotspotName = x.HotspotName,
                     Title = d.Title,
@@ -462,11 +522,12 @@ namespace Hotline.Api.Controllers.Bigscreen
         /// <returns></returns>
         [AllowAnonymous]
         [HttpGet("ordervisit-orgsatisfaction-rank")]
-        public async Task<List<OrderVisitOrgSatisfactionRankDto>> OrderVisitOrgSatisfactionRank(DateTime StartTime,DateTime EndTime)
+        public async Task<List<OrderVisitOrgSatisfactionRankDto>> OrderVisitOrgSatisfactionRank(DateTime StartTime, DateTime EndTime)
         {
-           var list = await _orderVisitDetailRepository.Queryable()
+            var list = await _orderVisitDetailRepository.Queryable()
                 .Includes(x => x.OrderVisit)
-                .Where(x => x.OrderVisit.VisitTime >= StartTime && x.OrderVisit.VisitTime <= EndTime && x.VisitTarget == EVisitTarget.Org && x.VisitOrgCode.Length >= 6 && x.OrderVisit.VisitState == EVisitState.Visited)
+                .Where(x => x.OrderVisit.VisitTime >= StartTime && x.OrderVisit.VisitTime <= EndTime && x.VisitTarget == EVisitTarget.Org &&
+                            x.VisitOrgCode.Length >= 6 && x.OrderVisit.VisitState == EVisitState.Visited)
                 .GroupBy(x => new
                 {
                     VisitOrgCode = x.VisitOrgCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")),
@@ -476,9 +537,12 @@ namespace Hotline.Api.Controllers.Bigscreen
                 {
                     VisitOrgCode = x.VisitOrgCode.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("6")),
                     VisitOrgName = x.VisitOrgName,
-                    SatisfiedCount = SqlFunc.AggregateSum(SqlFunc.IIF(SqlFunc.JsonField(x.OrgProcessingResults, "Key") != "1" && SqlFunc.JsonField(x.OrgProcessingResults, "Key") != "2", 1, 0)),
+                    SatisfiedCount =
+                        SqlFunc.AggregateSum(SqlFunc.IIF(
+                            SqlFunc.JsonField(x.OrgProcessingResults, "Key") != "1" && SqlFunc.JsonField(x.OrgProcessingResults, "Key") != "2", 1,
+                            0)),
                     VisitCount = SqlFunc.AggregateCount(x.VisitOrgName)
-                }).MergeTable().OrderByDescending(x=>x.SatisfiedCount).Take(10).ToListAsync();
+                }).MergeTable().OrderByDescending(x => x.SatisfiedCount).Take(10).ToListAsync();
             list = list.OrderByDescending(x => x.SatisfiedRate).ToList();
             return list;
         }
@@ -492,39 +556,39 @@ namespace Hotline.Api.Controllers.Bigscreen
         /// <returns></returns>
         [AllowAnonymous]
         [HttpGet("order-source-accepttype-statistics")]
-        public async Task<List<OrderSourceAndAcceptTtoeStatisticsDto>> OrderSourceAndAcceptTtoeStatistics(DateTime StartTime, DateTime EndTime, bool IsSource)
+        public async Task<List<OrderSourceAndAcceptTtoeStatisticsDto>> OrderSourceAndAcceptTtoeStatistics(DateTime StartTime, DateTime EndTime,
+            bool IsSource)
         {
             EndTime = EndTime.AddDays(1).AddSeconds(-1);
 
             int SumCount = await _orderRepository.Queryable(false, false, false)
-               .Where(x => x.StartTime >= StartTime && x.StartTime <= EndTime && x.Status > EOrderStatus.WaitForAccept).CountAsync();
+                .Where(x => x.StartTime >= StartTime && x.StartTime <= EndTime && x.Status > EOrderStatus.WaitForAccept).CountAsync();
             if (IsSource)
             {
                 var list = await _orderRepository.Queryable(false, false, false)
-                .Where(x => x.StartTime >= StartTime && x.StartTime <= EndTime && x.Status > EOrderStatus.WaitForAccept)
-                .GroupBy(x => new { x.SourceChannelCode, x.SourceChannel })
-                .Select(x => new OrderSourceAndAcceptTtoeStatisticsDto()
-                {
-                    Name = x.SourceChannel,
-                    SumCount = SumCount,
-                    HasCount = SqlFunc.AggregateCount(x.SourceChannel)
-                }).ToListAsync();
+                    .Where(x => x.StartTime >= StartTime && x.StartTime <= EndTime && x.Status > EOrderStatus.WaitForAccept)
+                    .GroupBy(x => new { x.SourceChannelCode, x.SourceChannel })
+                    .Select(x => new OrderSourceAndAcceptTtoeStatisticsDto()
+                    {
+                        Name = x.SourceChannel,
+                        SumCount = SumCount,
+                        HasCount = SqlFunc.AggregateCount(x.SourceChannel)
+                    }).ToListAsync();
                 return list;
             }
             else
             {
                 var list = await _orderRepository.Queryable(false, false, false)
-                .Where(x => x.StartTime >= StartTime && x.StartTime <= EndTime && x.Status > EOrderStatus.WaitForAccept)
-                .GroupBy( x => new { x.AcceptTypeCode, x.AcceptType })
-                .Select(x => new OrderSourceAndAcceptTtoeStatisticsDto()
-                {
-                    Name = x.AcceptType,
-                    SumCount = SumCount,
-                    HasCount = SqlFunc.AggregateCount(x.AcceptTypeCode),
-                }).ToListAsync();
+                    .Where(x => x.StartTime >= StartTime && x.StartTime <= EndTime && x.Status > EOrderStatus.WaitForAccept)
+                    .GroupBy(x => new { x.AcceptTypeCode, x.AcceptType })
+                    .Select(x => new OrderSourceAndAcceptTtoeStatisticsDto()
+                    {
+                        Name = x.AcceptType,
+                        SumCount = SumCount,
+                        HasCount = SqlFunc.AggregateCount(x.AcceptTypeCode),
+                    }).ToListAsync();
                 return list;
             }
         }
-
     }
-}
+}

+ 4 - 1
src/Hotline.Api/Controllers/OrderController.cs

@@ -3691,7 +3691,8 @@ public class OrderController : BaseController
                         nextflowDto.StepId = unhandleStep.Id;
                         nextflowDto.IsStartCountersign = lowerLevelHandlers.Count > 1;
                         nextflowDto.NextHandlers = lowerLevelHandlers;
-                        nextflowDto.Opinion = "跨级派单,自动办理";
+                        if(unhandleStep.Id != startStep.Id)
+                          nextflowDto.Opinion = "跨级派单,自动办理";
 
                         var operater = new FakeSessionContext
                         {
@@ -3753,6 +3754,8 @@ public class OrderController : BaseController
 
         rsp.TranspondCity = _sysDicDataCacheManager.GetSysDicDataCache(SysDicTypeConsts.TranspondCity)
             .ToList().Adapt<List<SystemDicDataOutDto>>();
+
+        rsp.CounterSignType = order.CounterSignType;
         return rsp;
     }
     

+ 3 - 0
src/Hotline.Api/config/appsettings.Development.json

@@ -3,6 +3,7 @@
   "AppConfiguration": {
     "AppScope": "ZiGong",
     "YiBin": {
+      "AreaCode": "511500",
       "CallCenterType": "TianRun", //XunShi、WeiErXin、TianRun、XingTang
       //智能回访
       "AiVisit": {
@@ -24,9 +25,11 @@
       }
     },
     "ZiGong": {
+      "AreaCode": "510300",
       "CallCenterType": "XingTang"
     },
     "LuZhou": {
+      "AreaCode": "510500",
       "CallCenterType": "XingTang"
     }
   },

+ 43 - 29
src/Hotline.Application/FlowEngine/WorkflowApplication.cs

@@ -541,7 +541,8 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
         var workflow = await _workflowDomainService.GetWorkflowAsync(workflowId, withDefine: true, withSteps: true,
             cancellationToken: cancellationToken);
         var currentStep = _workflowDomainService.FindCurrentStepWaitForHandle(workflow,
-            _sessionContextProvider.SessionContext.RequiredUserId, _sessionContextProvider.SessionContext.RequiredOrgId, _sessionContextProvider.SessionContext.Roles);
+            _sessionContextProvider.SessionContext.RequiredUserId, _sessionContextProvider.SessionContext.RequiredOrgId,
+            _sessionContextProvider.SessionContext.Roles);
         if (currentStep.StepType is EStepType.End)
             throw new UserFriendlyException("结束节点无需办理");
 
@@ -578,6 +579,7 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
             var workflow = await _workflowDomainService.GetWorkflowAsync(dto.WorkflowId, withDefine: true, cancellationToken: cancellationToken);
             definition = workflow.WorkflowDefinition;
         }
+
         if (definition == null)
             throw new UserFriendlyException("无效模板编码");
         if (definition.Status is not EDefinitionStatus.Enable)
@@ -604,16 +606,16 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
             };
             var orgs = await _organizeRepository.Queryable()
                 .Where(d => d.IsEnable &&
-                d.Level == orgLevel &&
-                dto.OrgIds.Contains(d.ParentId))
+                            d.Level == orgLevel &&
+                            dto.OrgIds.Contains(d.ParentId))
                 .ToListAsync(cancellationToken);
             nextStepOption.Items = orgs.Select(d => new FlowStepHandler
-            {
-                Key = d.Id,
-                Value = d.Name,
-                OrgId = d.Id,
-                OrgName = d.Name
-            })
+                {
+                    Key = d.Id,
+                    Value = d.Name,
+                    OrgId = d.Id,
+                    OrgName = d.Name
+                })
                 .ToList();
             nextStepOption.FlowDirection = _workflowDomainService.GetFlowDirection(dto.BusinessType, stepDefine.BusinessType);
             stepOptions.Add(nextStepOption);
@@ -972,8 +974,7 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
             case EHandlerType.Role:
                 //当前操作人所属部门的下级部门并且属于配置包含角色
                 var roles = await _roleRepository.Queryable()
-                    .Includes(
-                        d => d.Accounts.Where(x =>
+                    .Includes(d => d.Accounts.Where(x =>
                             !x.IsDeleted && x.Status == EAccountStatus.Normal && x.AccountType == EAccountType.Personal).ToList(),
                         x => x.User, s => s.Organization)
                     .Where(d => stepDefine.HandlerTypeItems.Select(x => x.Key).Contains(d.Name))
@@ -981,10 +982,20 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
                 _logger.LogInformation($"角色: {string.Join(",", roles.Select(d => d.Name))}");
                 var users1 = roles.SelectMany(d => d.Accounts).Select(d => d.User);
 
-                //工单办理:除一级部门选择中心汇总(中心会签流程,返回topCountersignStep场景),其余只能选下级部门
-                if (flowType is EFlowType.Handle
-                    && (stepDefine.StepType != EStepType.Summary && stepDefine.BusinessType != EBusinessType.Seat))
-                    users1 = users1.Where(d => d.OrgId.StartsWith(levelOneOrgId));
+                if (flowType is EFlowType.Handle)
+                {
+                    //工单办理:除一级部门选择中心汇总(中心会签流程,返回topCountersignStep场景),其余只能选下级部门
+                    if (stepDefine.BusinessType is EBusinessType.Department &&
+                        stepDefine.StepType != EStepType.Summary)
+                    {
+                        users1 = users1.Where(d => d.OrgId.StartsWith(levelOneOrgId));
+                    }
+                    else if(stepDefine.BusinessType is EBusinessType.DepartmentLeader)
+                    {
+                        users1 = users1.Where(d => d.OrgId == orgId);
+                    }
+                }
+
                 var defineTypeItem = stepDefine.HandlerTypeItems.First();
 
                 handlers = users1.Where(d => d != null && !string.IsNullOrEmpty(d.Id))
@@ -1030,12 +1041,12 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
                 }
 
                 handlers = orgs1.Select(d => new FlowStepHandler
-                {
-                    Key = d.Id,
-                    Value = d.Name,
-                    OrgId = d.Id,
-                    OrgName = d.Name
-                })
+                    {
+                        Key = d.Id,
+                        Value = d.Name,
+                        OrgId = d.Id,
+                        OrgName = d.Name
+                    })
                     .ToList();
                 break;
             case EHandlerType.OrgType:
@@ -1047,12 +1058,12 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
                     .ToListAsync(cancellationToken);
 
                 handlers = orgs2.Select(d => new FlowStepHandler
-                {
-                    Key = d.Id,
-                    Value = d.Name,
-                    OrgId = d.Id,
-                    OrgName = d.Name
-                })
+                    {
+                        Key = d.Id,
+                        Value = d.Name,
+                        OrgId = d.Id,
+                        OrgName = d.Name
+                    })
                     .ToList();
                 break;
             default:
@@ -1322,7 +1333,9 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
                     if (!isLead)
                     {
                         isSkip = await _userRepository.Queryable()
-                            .AnyAsync(x => x.OrgId == _sessionContextProvider.SessionContext.RequiredOrgId && x.Roles.Any(r => r.Name == leadRoleCode), cancellationToken);
+                            .AnyAsync(
+                                x => x.OrgId == _sessionContextProvider.SessionContext.RequiredOrgId && x.Roles.Any(r => r.Name == leadRoleCode),
+                                cancellationToken);
                         if (isSkip)
                         {
                             roleId = leadRoleCode;
@@ -1366,7 +1379,8 @@ public class WorkflowApplication : IWorkflowApplication, IScopeDependency
                 if (!isLead)
                 {
                     isSkip = await _userRepository.Queryable()
-                        .AnyAsync(x => x.OrgId == _sessionContextProvider.SessionContext.RequiredOrgId && x.Roles.Any(r => r.Name == leadRoleCode), cancellationToken);
+                        .AnyAsync(x => x.OrgId == _sessionContextProvider.SessionContext.RequiredOrgId && x.Roles.Any(r => r.Name == leadRoleCode),
+                            cancellationToken);
                     if (isSkip)
                     {
                         roleId = leadRoleCode;

+ 5 - 0
src/Hotline.Share/Dtos/FlowEngine/NextStepsDto.cs

@@ -69,6 +69,11 @@ public class NextStepsWithOpinionDto<TSteps> : NextStepsDto<TSteps>
     /// 市州转办信息
     /// </summary>
     public List<SystemDicDataOutDto>? TranspondCity { get; set; }
+
+    /// <summary>
+    /// 会签类型:null:非会签,0:中心会签,1:部门会签
+    /// </summary>
+    public ECounterSignType? CounterSignType { get; set; }
 }
 
 public class StepTempInDto

+ 3 - 3
src/Hotline.Share/Dtos/Order/OrderDto.cs

@@ -121,8 +121,8 @@ namespace Hotline.Share.Dtos.Order
         public double HandleDurationWorkday { get; set; }
 
         /// <summary>
-        /// 全流程时长(分钟
-        /// 归档时间-创建时间
+        /// 全流程时长(
+        /// 归档时间-受理时间
         /// </summary>
         public double AllDuration { get; set; }
 
@@ -134,7 +134,7 @@ namespace Hotline.Share.Dtos.Order
 
 			if (Status >= EOrderStatus.Filed)
 			{
-                return  Math.Round(AllDuration / 60, 2).ToString() + "小时";
+                return  Math.Round(Math.Round((FiledTime - CreationTime).Value.TotalSeconds) / 60 / 60, 2).ToString() + "小时";
 			}
             return "-";
         }

+ 4 - 0
src/Hotline/Configurations/AppConfiguration.cs

@@ -49,6 +49,10 @@ namespace Hotline.Configurations
 
     public abstract class DefaultAppScopeConfiguration
     {
+        /// <summary>
+        /// 行政区划编码
+        /// </summary>
+        public string AreaCode { get; set; }
         public string CallCenterType { get; set; }
     }
 }

+ 6 - 4
src/Hotline/FlowEngine/Workflows/WorkflowDomainService.cs

@@ -198,6 +198,8 @@ namespace Hotline.FlowEngine.Workflows
                 _sessionContext.RequiredUserId, _sessionContext.RequiredOrgId,
                 externalId, cancellationToken);
 
+            //todo 重构为流程开放策略参数,业务决定
+            var defineHandler = startStepDefine.HandlerTypeItems.First();
             var startStep = CreateStartStep(workflow, startStepDefine, dto,
                 new FlowStepHandler
                 {
@@ -207,8 +209,8 @@ namespace Hotline.FlowEngine.Workflows
                     Username = _sessionContext.UserName,
                     OrgId = _sessionContext.RequiredOrgId,
                     OrgName = _sessionContext.OrgName,
-                    // RoleId = defineHandler.Key,
-                    // RoleName = defineHandler.Value,
+                    RoleId = defineHandler.Key,
+                    RoleName = defineHandler.Value,
                 }, expiredTime);
 
             if (dto.Files.Any())
@@ -371,7 +373,7 @@ namespace Hotline.FlowEngine.Workflows
             if (isStartCountersign)
             {
                 var exists = workflow.Countersigns.Any(d =>
-                    !d.IsCompleted() && d.StarterId == current.UserId);
+                    !d.IsCompleted() && !string.IsNullOrEmpty(current.UserId) && d.StarterId == current.UserId);
                 if (exists)
                     throw new UserFriendlyException("该用户在当前流程存在未结束会签");
                 await StartCountersignAsync(current, workflow, currentStep, dto, flowAssignInfo.FlowAssignType,
@@ -2385,7 +2387,7 @@ namespace Hotline.FlowEngine.Workflows
             {
                 //newStep.FlowAssignType = EFlowAssignType.User;
                 // 是否中心  临时紧急修改 后续在流程模版定义是否原办理人退回类型 来实现流程 禅道200
-                newStep.FlowAssignType = step.HandlerOrgIsCenter!.Value
+                newStep.FlowAssignType = step.BusinessType is EBusinessType.Seat or EBusinessType.Send
                     ? step.BusinessType is EBusinessType.Send ? EFlowAssignType.User : EFlowAssignType.Role
                     : EFlowAssignType.Org;
                 //if (newStep is { FlowAssignType: EFlowAssignType.Role, BusinessType: EBusinessType.Send })