From 38eef5ea4b8391a2444af56cfdfd528a58184336 Mon Sep 17 00:00:00 2001
From: 快乐的昕的电脑 <快乐的昕的电脑@DESKTOP-C2BQPQU>
Date: 星期一, 20 十月 2025 11:12:49 +0800
Subject: [PATCH] 计算日停机次数
---
Entites/DbModels/VOrderBycl.cs | 1 +
Services/WomdaaManager.cs | 34 +++++++++++++++++++++++++++++++---
2 files changed, 32 insertions(+), 3 deletions(-)
diff --git a/Entites/DbModels/VOrderBycl.cs b/Entites/DbModels/VOrderBycl.cs
index d8d8413..5153ec4 100644
--- a/Entites/DbModels/VOrderBycl.cs
+++ b/Entites/DbModels/VOrderBycl.cs
@@ -202,4 +202,5 @@
[SugarColumn(IsIgnore = true)] public long? StartCjNum { get; set; }//寮�宸ユ暟閲�(鏈�鏃╅噰闆嗗��)
[SugarColumn(IsIgnore = true)] public long? CurrentCjNum { get; set; }//褰撳墠鏁伴噰(鏈�鏂伴噰闆嗗��)
[SugarColumn(IsIgnore = true)] public long? InitCjNum { get; set; }//鍒濆閲囬泦鏁�
+ [SugarColumn(IsIgnore = true)] public int TodayDowntimeCount { get; set; }//浠婃棩鍋滄満娆℃暟
}
\ No newline at end of file
diff --git a/Services/WomdaaManager.cs b/Services/WomdaaManager.cs
index 4233ec3..59d2293 100644
--- a/Services/WomdaaManager.cs
+++ b/Services/WomdaaManager.cs
@@ -256,6 +256,9 @@
VOrdrerBycl.CurrentCjNum = 0;
}
+ // 璁$畻褰撳ぉ鍋滄満娆℃暟
+ VOrdrerBycl.TodayDowntimeCount = GetTodayDowntimeCount(numericalList);
+
Console.WriteLine($"orderNo: [{query.orderNo}]");
// 鏌ヨ鎶ュ伐璁板綍锛岃幏鍙栨渶鍚庝竴鏉℃姤宸ヨ褰�
@@ -282,13 +285,38 @@
VOrdrerBycl.InitCjNum = beforeOrEqualReportNum?.CjNum ?? VOrdrerBycl.StartCjNum;
}
- // 鎶ュ伐鏃堕噰闆嗘暟灏辨槸涓荤晫闈㈢殑褰撳墠閲囨暟
- // VOrdrerBycl.CurrentCjNum 宸茶祴鍊硷紝鏃犻渶棰濆澶勭悊
-
return VOrdrerBycl;
}
/// <summary>
+ /// 璁$畻鏃ュ仠鏈烘鏁�
+ /// </summary>
+ /// <param name="numericalList"></param>
+ /// <returns></returns>
+ public int GetTodayDowntimeCount(List<MesNumericalBycl> numericalList)
+ {
+ var today = DateTime.Now.Date;
+ // 1. 鍙繚鐣欏綋澶╂暟鎹紝骞惰浆鎹负 DateTime
+ var todayTimes = numericalList
+ .Where(x => DateTime.TryParse(x.CjTiem, out var dt) && dt.Date == today)
+ .Select(x => DateTime.Parse(x.CjTiem))
+ .OrderBy(x => x)
+ .ToList();
+
+ if (todayTimes.Count < 2)
+ return 0;
+
+ int downtimeCount = 0;
+ for (int i = 1; i < todayTimes.Count; i++)
+ {
+ var diff = (todayTimes[i] - todayTimes[i - 1]).TotalMinutes;
+ if (diff > 3)
+ downtimeCount++;
+ }
+ return downtimeCount;
+ }
+
+ /// <summary>
/// 鏍规嵁宸ュ崟ID鑾峰彇鎶ュ伐淇℃伅
/// </summary>
/// <param name="query">鍖呭惈宸ュ崟ID鐨勬煡璇㈡潯浠�</param>
--
Gitblit v1.9.3