Browse Source

处理宜宾综合查询速度满的问题

Dun.Jason 5 months ago
parent
commit
fafa43f69f
2 changed files with 62 additions and 5 deletions
  1. 8 5
      src/Hotline.Application/Orders/OrderApplication.cs
  2. 54 0
      src/Hotline/dataview.md

+ 8 - 5
src/Hotline.Application/Orders/OrderApplication.cs

@@ -1059,10 +1059,13 @@ public class OrderApplication : IOrderApplication, IScopeDependency
                                step.TraceState != EWorkflowTraceState.StepRemoveByRecall).Any());
         }
 
-        return query
-             .Includes(x => x.OrderScreens)
-             .Includes(x => x.OrderVisits.Where(m => m.VisitState == EVisitState.Visited).ToList())
-             .Includes(x => x.OrderVisits.Where(m => m.VisitState == EVisitState.Visited).ToList(), ovd => ovd.OrderVisitDetails)
+            query = query.Includes(x => x.OrderScreens);
+            if (!_appOptions.Value.IsYiBin)
+            {
+                query = query.Includes(x => x.OrderVisits.Where(m => m.VisitState == EVisitState.Visited).ToList())
+             .Includes(x => x.OrderVisits.Where(m => m.VisitState == EVisitState.Visited).ToList(), ovd => ovd.OrderVisitDetails);
+            }
+            query = query
              .WhereIF(!string.IsNullOrEmpty(dto.Keyword), d => d.Title.Contains(dto.Keyword!)) //标题
              .WhereIF(!string.IsNullOrEmpty(dto.ProvinceNo), d => d.ProvinceNo == dto.ProvinceNo) //省本地编号
              .WhereIF(!string.IsNullOrEmpty(dto.ReceiveProvinceNo), d => d.ReceiveProvinceNo == dto.ReceiveProvinceNo) //省编号
@@ -1171,7 +1174,7 @@ public class OrderApplication : IOrderApplication, IScopeDependency
              .OrderByIF(dto is { SortField: "acceptorName",SortRule:1 },d=>d.AcceptorName,OrderByType.Desc) //受理人降序
              ;
 
-
+        return query;
     }
 
     /// <summary>

+ 54 - 0
src/Hotline/dataview.md

@@ -458,3 +458,57 @@ where visittemp."CreationTime">='2024-08-29' and visitdetailtemp."VisitTarget"=1
 on aaa."SugarNav_Id" = ccc."OrderId"
 
 
+### 重置工单回访部门信息
+update order_visit_detail set 
+"VisitOrgCode"= hhh."HandlerOrgId","VisitOrgName"=hhh."HandlerOrgName"
+from (
+select * from (
+select ppp."OrderId",ooo."Id" "VisitDetailId" from(
+select "Id","OrderId" from order_visit where "VisitState" <> 50 and "OrderId" in(
+select "Id" from "order" WHERE "FiledTime">'2024-10-30' and "ActualHandleOrgCode" <> '001' and "Status">300 and "CounterSignType" is null)) ppp
+left join order_visit_detail ooo on ppp."Id"=ooo."VisitId"
+WHERE ooo."VisitTarget"=20) qqq
+left join 
+(select aaa.* from workflow_step aaa
+left join (
+select "ExternalId","max"("HandleTime") maxTime from workflow_step where "WorkflowId" in(
+select "WorkflowId" from "order" WHERE "FiledTime">'2024-10-30' and "ActualHandleOrgCode"<>'001' and "Status">=300 and "CounterSignType" is null)
+and  "StepType" not in (2,3) AND "IsOrigin"=TRUE group  by "ExternalId") bbb on aaa."ExternalId"=bbb."ExternalId" 
+where aaa."HandleTime"=bbb.maxTime) www on qqq."OrderId"= www."ExternalId") hhh
+where order_visit_detail."Id" = hhh."VisitDetailId" and hhh."OrderId"='08dcf7df-964a-436c-8f39-bc96ff54522a'
+
+
+### 重置工单实际办理部门和接办信息
+update  "order" uuu
+set
+"ActualHandleOrgName"=ccc."HandlerOrgName","ActualHandleOrgCode"=ccc."HandlerOrgId","CurrentHandleOrgId"=ccc."HandlerOrgId","CurrentHandlerName"=ccc."HandlerOrgName"
+from (
+select aaa."ExternalId",aaa."HandlerOrgId",aaa."HandlerOrgName" from workflow_step aaa
+left join (
+select "ExternalId","max"("HandleTime") maxTime from workflow_step where "WorkflowId" in(
+select "WorkflowId" from "order" WHERE "FiledTime">'2024-10-30' and "ActualHandleOrgCode"<>'001' and "Status">=300 and "CounterSignType" is null)
+and  "StepType" not in (2,3) AND "IsOrigin"=TRUE group  by "ExternalId") bbb on aaa."ExternalId"=bbb."ExternalId" 
+where aaa."HandleTime"=bbb.maxTime) ccc where uuu."Id"=ccc."ExternalId" and uuu."Id"='08dcf7df-964a-436c-8f39-bc96ff54522a'
+
+
+
+### 查询智能回访超过两次的回访工单
+update order_visit_detail set "SeatEvaluate"=4,"VisitContent"='市民未接听电话。'
+where "VisitId" in(
+select "Id" from order_visit WHERE "OrderId" in(
+select "OrderId" from ai_order_visit_detail where "CreationTime">'2024-10-29'
+and "CallTimes">0 and "AiSeatEvaluate" is null and "AiIsContact" is null and "AiVolved" is  NULL  and "AiOrgProcessingResults" is null
+group by "OrderId") and "VisitState" not in(50,30)) and "VisitTarget"=10;
+
+
+update order_visit_detail set "OrgProcessingResults" ='{"Key":"6","Value":"未接通"}',"VisitContent"='市民未接听电话。',"IsContact"=TRUE,"Volved"=true
+where "VisitId" in(
+select "Id" from order_visit WHERE "OrderId" in(
+select "OrderId" from ai_order_visit_detail where "CreationTime">'2024-10-29'
+and "CallTimes">0 and "AiSeatEvaluate" is null and "AiIsContact" is null and "AiVolved" is  NULL  and "AiOrgProcessingResults" is null
+group by "OrderId") and "VisitState" not in(50,30)) and "VisitTarget"=20
+
+
+
+
+