From 1cbb7eb74db8d7aca767cc2b47b8accf1c34eb86 Mon Sep 17 00:00:00 2001 From: wangsr Date: Tue, 7 Nov 2023 14:54:26 +0800 Subject: [PATCH] =?UTF-8?q?change=20-=20=E6=8A=A5=E8=A1=A8=E6=97=B6?= =?UTF-8?q?=E5=88=86=E7=A7=92=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LjReport/WetTimeCounting.cs | 34 ++++++++++++++----- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjReport/WetTimeCounting.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjReport/WetTimeCounting.cs index 4bdcbf3..709ed75 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjReport/WetTimeCounting.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjReport/WetTimeCounting.cs @@ -129,9 +129,9 @@ namespace Mesnac.Action.ChemicalWeighing.LjReport for (int i = 0; i < listMore.Count; i++) { var dr = MoreDataTable.NewRow(); - dr[0] = listMore[i].MixWaitTime; - dr[1] = listMore[i].RgvWaitTime; - dr[2] = listMore[i].MixWaitTime + listMore[i].RgvWaitTime; + dr[0] = TimeConvert(listMore[i].MixWaitTime); + dr[1] = TimeConvert(listMore[i].RgvWaitTime); + dr[2] = TimeConvert(listMore[i].MixWaitTime + listMore[i].RgvWaitTime); dr[3] = listMore[i].MixReadyStartTime; dr[4] = listMore[i].RGVLeaveTime; MoreDataTable.Rows.Add(dr); @@ -201,29 +201,45 @@ namespace Mesnac.Action.ChemicalWeighing.LjReport var dr = dt.NewRow(); dr[0] = "湿混机" + i; var MixWaitTime = list.Where(x => x.DeviceNo == i).Sum(x => x.MixWaitTime); - dr[1] = MixWaitTime.ToString(); + dr[1] = TimeConvert(MixWaitTime); var RGVWaitTime = list.Where(x => x.DeviceNo == i).Sum(x => x.RgvWaitTime); - dr[2] = RGVWaitTime.ToString(); + dr[2] = TimeConvert(RGVWaitTime); var totalTime = MixWaitTime + RGVWaitTime; - dr[3] = totalTime.ToString(); + dr[3] = TimeConvert(totalTime); dt.Rows.Add(dr); } var edr = dt.NewRow(); edr[0] = "湿混等待时间总和"; - edr[1] = list.Sum(x => x.MixWaitTime).ToString(); + edr[1] = TimeConvert(list.Sum(x => x.MixWaitTime)); dt.Rows.Add(edr); var edr1 = dt.NewRow(); edr1[0] = "RGV等待时间总和"; - edr1[1] = list.Sum(x => x.RgvWaitTime).ToString(); + edr1[1] = TimeConvert(list.Sum(x => x.RgvWaitTime)); dt.Rows.Add(edr1); var edr2 = dt.NewRow(); edr2[0] = "总等待时间总和"; - edr2[1] = list.Sum(x => x.MixWaitTime + x.RgvWaitTime).ToString(); + edr2[1] = TimeConvert(list.Sum(x => x.MixWaitTime + x.RgvWaitTime)); dt.Rows.Add(edr2); dataGridView.DataSource = null; dataGridView.DataSource = dt; } + + private string TimeConvert(int t) + { + int h = t / 3600; + int m = t / 60; + int s = t % 60; + if (h != 0) + { + return h + "时" + m + "分" + s + "秒"; + } + if (m != 0) + { + return m + "分" + s + "秒"; + } + return s + "秒"; + } } }