田爽 3 сар өмнө
parent
commit
cff308712d

+ 23 - 21
src/Hotline.Api/Controllers/TestController.cs

@@ -1373,33 +1373,35 @@ ICallApplication callApplication,
         }
     }
 
-    /// <summary>
-    /// 老系统数据同步
-    /// </summary>
-    /// <returns></returns>
-	[HttpGet("old_data_synchronization/{no}")]
+	/// <summary>
+	/// 老系统数据同步
+	/// </summary>
+	/// <returns></returns>
+	[HttpGet("old_data_synchronization")]
 	[AllowAnonymous]
-	public async Task oldDataSynchronization(string no) 
-    {
-        var orders = new List<Order>();
-        if (string.IsNullOrEmpty(no))
-        {
-            orders = await _orderRepository.Queryable().Where(x => x.No.Length == 12 && x.ActualHandleTime == null  &&  x.CenterToOrgTime == null).ToListAsync();
-        }
-        else {
+	public async Task oldDataSynchronization([FromQuery] string? no)
+	{
+		var orders = new List<Order>();
+		if (string.IsNullOrEmpty(no))
+		{
+			orders = await _orderRepository.Queryable().Where(x => x.No.Length == 12 && x.ActualHandleTime == null && x.CenterToOrgTime == null).ToListAsync();
+		}
+		else
+		{
 			orders = await _orderRepository.Queryable().Where(x => x.No == no).ToListAsync();
 		}
-        foreach (var order in orders) {
+		foreach (var order in orders)
+		{
 
-            var  steps = await _workflowStepRepository.Queryable().Where(x=>x.ExternalId == order.Id).ToListAsync();
+			var steps = await _workflowStepRepository.Queryable().Where(x => x.ExternalId == order.Id).ToListAsync();
 
-            var actualHandleStep = steps.Where(x => x.HandlerOrgId == order.ActualHandleOrgCode).OrderByDescending(x => x.CreationTime).FirstOrDefault();
-            var CenterToOrgStep = steps.Where(x => x.AssignerOrgId == "001" && x.HandlerOrgId  != "001").OrderByDescending(x => x.CreationTime).FirstOrDefault();
+			var actualHandleStep = steps.Where(x => x.HandlerOrgId == order.ActualHandleOrgCode).OrderByDescending(x => x.CreationTime).FirstOrDefault();
+			var CenterToOrgStep = steps.Where(x => x.AssignerOrgId == "001" && x.HandlerOrgId != "001").OrderByDescending(x => x.CreationTime).FirstOrDefault();
 
 			order.ActualHandleTime = actualHandleStep.HandleTime;
-            order.CenterToOrgTime = CenterToOrgStep.CreationTime;
+			order.CenterToOrgTime = CenterToOrgStep.CreationTime;
 
-            await _orderRepository.Updateable().SetColumns(x => new Order { ActualHandleTime = order.ActualHandleTime, CenterToOrgTime = order.CenterToOrgTime }).ExecuteCommandAsync();
+			await _orderRepository.Updateable().SetColumns(x => new Order { ActualHandleTime = order.ActualHandleTime, CenterToOrgTime = order.CenterToOrgTime }).Where(x => x.Id == order.Id).ExecuteCommandAsync();
 
 
 			var now = order.FiledTime.Value;
@@ -1442,8 +1444,8 @@ ICallApplication callApplication,
 			order.File(now, handleDuration, fileDuration, allDuration, creationTimeHandleDurationWorkday, centerToOrgHandleDurationWorkday);
 
 		}
-       
-    }
+
+	}
 
 
 }