Просмотр исходного кода

fix: commonp 甄别查询条件调整 visitState.Visited

xf 10 месяцев назад
Родитель
Сommit
853624a5a0
1 измененных файлов с 38 добавлено и 38 удалено
  1. 38 38
      src/Hotline.Api/Controllers/CommonPController.cs

+ 38 - 38
src/Hotline.Api/Controllers/CommonPController.cs

@@ -22,7 +22,7 @@ namespace Hotline.Api.Controllers
     /// <summary>
     /// 常用意见接口
     /// </summary>
-    public class CommonPController: BaseController
+    public class CommonPController : BaseController
     {
         private readonly ISystemCommonOpinionDomainService _commonOpinionDomainService;
         private readonly ISystemAreaDomainService _systemAreaDomainService;
@@ -35,20 +35,20 @@ namespace Hotline.Api.Controllers
         private readonly IOrderScreenRepository _orderScreenRepository;
         private readonly IRepository<OrderVisitDetail> _orderVisitedDetailRepository;
 
-		public CommonPController(
+        public CommonPController(
             ISystemCommonOpinionDomainService commonOpinionDomainService,
             ISystemAreaDomainService systemAreaDomainService,
             ISessionContext sessionContext,
             IRepository<TrCallRecord> trCallRecordRepository,
             IOrderRepository orderRepository,
-			IMapper mapper,
+            IMapper mapper,
             IOrderDelayRepository orderDelayRepository,
             ITimeLimitDomainService timeLimitDomainService,
             IOrderScreenRepository orderScreenRepository,
             IRepository<OrderVisitDetail> orderVisitedDetailRepository)
         {
             _commonOpinionDomainService = commonOpinionDomainService;
-            _systemAreaDomainService= systemAreaDomainService;
+            _systemAreaDomainService = systemAreaDomainService;
             _mapper = mapper;
             _sessionContext = sessionContext;
             _trCallRecordRepository = trCallRecordRepository;
@@ -56,10 +56,10 @@ namespace Hotline.Api.Controllers
             _orderDelayRepository = orderDelayRepository;
             _timeLimitDomainService = timeLimitDomainService;
             _orderScreenRepository = orderScreenRepository;
-            _orderVisitedDetailRepository= orderVisitedDetailRepository;
-		}
+            _orderVisitedDetailRepository = orderVisitedDetailRepository;
+        }
+
 
-       
 
         #region 省市区
         /// <summary>
@@ -80,34 +80,34 @@ namespace Hotline.Api.Controllers
         /// </summary>
         /// <returns></returns>
         [HttpGet("home_data")]
-        public async Task<Object> GetHomeData() 
+        public async Task<Object> GetHomeData()
         {
             var tadayTime = DateTime.Now.ToString("yyyy-MM-dd");
-			//中心
-			if (_sessionContext.OrgIsCenter)
-	        {
-		        var orderQuery = _orderRepository.Queryable(false, false, false)
-			        .Includes(o => o.Workflow, w => w.Steps);
-				//今日来电
-				var tadayCalls = await _trCallRecordRepository.Queryable()
-	                .Where(x => x.CallDirection == Share.Enums.CallCenter.ECallDirection.In && tadayTime.Equals(x.CreatedTime.ToString("yyyy-MM-dd"))).ToListAsync();
-				var callNum = tadayCalls.Count();
+            //中心
+            if (_sessionContext.OrgIsCenter)
+            {
+                var orderQuery = _orderRepository.Queryable(false, false, false)
+                    .Includes(o => o.Workflow, w => w.Steps);
+                //今日来电
+                var tadayCalls = await _trCallRecordRepository.Queryable()
+                    .Where(x => x.CallDirection == Share.Enums.CallCenter.ECallDirection.In && tadayTime.Equals(x.CreatedTime.ToString("yyyy-MM-dd"))).ToListAsync();
+                var callNum = tadayCalls.Count();
                 var validCallNum = tadayCalls.Where(x => x.Duration > 0 || x.QueueTims > 0 || x.RingTimes > 0).Count();
-				//今日接通率
-                var answeredNum = tadayCalls.Where(x=>x.Duration > 0).Count();
-				var answeredRate = validCallNum > 0 ? Math.Round((double.Parse(answeredNum.ToString()) / double.Parse(validCallNum.ToString())) * 100, 2) + "%" : "-";
-				//今日受理工单
-				var tadayOrders = await orderQuery
-	                .Where(o => tadayTime.Equals(o.CreationTime.ToString("yyyy-MM-dd"))).ToListAsync();
-				var orderNum = tadayOrders.Count();
-				var directlyNum = tadayOrders.Where(o=> o.ProcessType == Share.Enums.Order.EProcessType.Zhiban).Count();
+                //今日接通率
+                var answeredNum = tadayCalls.Where(x => x.Duration > 0).Count();
+                var answeredRate = validCallNum > 0 ? Math.Round((double.Parse(answeredNum.ToString()) / double.Parse(validCallNum.ToString())) * 100, 2) + "%" : "-";
+                //今日受理工单
+                var tadayOrders = await orderQuery
+                    .Where(o => tadayTime.Equals(o.CreationTime.ToString("yyyy-MM-dd"))).ToListAsync();
+                var orderNum = tadayOrders.Count();
+                var directlyNum = tadayOrders.Where(o => o.ProcessType == Share.Enums.Order.EProcessType.Zhiban).Count();
                 return new { CallNum = callNum, ValidCallNum = validCallNum, AnsweredNum = answeredNum, AnsweredRate = answeredRate, OrderNum = orderNum, DirectlyNum = directlyNum };
-			}
+            }
             //部门
             //今日待办 tasksOkNum
             //var time = DateTime.Parse(tadayTime);
             //工单
-			var order = await _orderRepository.Queryable()
+            var order = await _orderRepository.Queryable()
                .Where(o => SqlFunc.JsonListObjectAny(o.HandlerUsers, "Key", _sessionContext.RequiredUserId) || SqlFunc.JsonListObjectAny(o.HandlerOrgs, "Key", _sessionContext.RequiredOrgId))
                .GroupBy(o => o.Id).MergeTable()
                .Select(o => new
@@ -116,32 +116,32 @@ namespace Hotline.Api.Controllers
                    havExpired = SqlFunc.AggregateSum(SqlFunc.IIF(DateTime.Now > o.ExpiredTime!.Value, 1, 0)),
                    countersignHandle = SqlFunc.AggregateSum(SqlFunc.IIF(o.CounterSignType.HasValue, 1, 0)),
 
-			   }).FirstAsync();
+               }).FirstAsync();
             var aboutExpire = order?.aboutExpire ?? 0;
             var havExpired = order?.havExpired ?? 0;
             var countersignHandle = order?.countersignHandle ?? 0;
             //延期
             var delay = await _orderDelayRepository.Queryable()
-                .Includes(x=>x.Workflow)
-                .Where(x=> SqlFunc.JsonListObjectAny(x.HandlerUsers, "Key", _sessionContext.RequiredUserId) || SqlFunc.JsonListObjectAny(x.HandlerOrgs, "Key", _sessionContext.RequiredOrgId))
+                .Includes(x => x.Workflow)
+                .Where(x => SqlFunc.JsonListObjectAny(x.HandlerUsers, "Key", _sessionContext.RequiredUserId) || SqlFunc.JsonListObjectAny(x.HandlerOrgs, "Key", _sessionContext.RequiredOrgId))
                 .Where(x => x.DelayState == EDelayState.Examining).CountAsync();
             //甄别
             var screenAudit = await _orderScreenRepository.Queryable()
-                .Includes(x=>x.Workflow)
-				 .Where(x => SqlFunc.JsonListObjectAny(x.HandlerUsers, "Key", _sessionContext.RequiredUserId) || SqlFunc.JsonListObjectAny(x.HandlerOrgs, "Key", _sessionContext.RequiredOrgId))
-				.Where(x =>  x.Status == EScreenStatus.Apply)
+                .Includes(x => x.Workflow)
+                 .Where(x => SqlFunc.JsonListObjectAny(x.HandlerUsers, "Key", _sessionContext.RequiredUserId) || SqlFunc.JsonListObjectAny(x.HandlerOrgs, "Key", _sessionContext.RequiredOrgId))
+                .Where(x => x.Status == EScreenStatus.Apply)
                 .CountAsync();
-			var workTime = _timeLimitDomainService.CalcWorkTimeReduce(DateTime.Now, 5);
-			var screenHandle = await _orderVisitedDetailRepository.Queryable(false, true)
+            var workTime = _timeLimitDomainService.CalcWorkTimeReduce(DateTime.Now, 5);
+            var screenHandle = await _orderVisitedDetailRepository.Queryable(false, true)
                 .Includes(x => x.OrderVisit)
                 .LeftJoin<OrderScreen>((x, s) => x.Id == s.VisitDetailId && s.Status < EScreenStatus.End && s.IsDeleted == false)
                 .Where((x, s) => s.Id == null)
                 .Where(x => x.OrderVisit.VisitTime < DateTime.Now && x.OrderVisit.VisitTime > workTime)
-                .Where((x, s) => x.OrderVisit.VisitState != EVisitState.None && x.OrderVisit.IsCanHandle)
+                .Where((x, s) => x.OrderVisit.VisitState == EVisitState.Visited && x.OrderVisit.IsCanHandle)
                 .Where((x, s) => x.VisitTarget == EVisitTarget.Org && x.VisitOrgCode == _sessionContext.OrgId && (
                 SqlFunc.JsonField(x.OrgProcessingResults, "Key") == "1" || SqlFunc.JsonField(x.OrgProcessingResults, "Key") == "2" ||
                 SqlFunc.JsonField(x.OrgHandledAttitude, "Key") == "1" || SqlFunc.JsonField(x.OrgHandledAttitude, "Key") == "2")).CountAsync();
-			return new { AboutExpire = aboutExpire, HavExpired = havExpired, CountersignHandle = countersignHandle, ScreenAudit = screenAudit, Delay = delay, ScreenHandle = screenHandle };
+            return new { AboutExpire = aboutExpire, HavExpired = havExpired, CountersignHandle = countersignHandle, ScreenAudit = screenAudit, Delay = delay, ScreenHandle = screenHandle };
         }
-	}
+    }
 }