|
@@ -14,13 +14,13 @@ public class TaskComponent : Component
|
|
|
public List<SeaSJRescueMission> SeaSJRescueMissions;
|
|
|
|
|
|
public SJAllTotalTaskPerformanceComponent SJAllTotalTaskPerformance = new SJAllTotalTaskPerformanceComponent();
|
|
|
- public Dictionary<string, Dictionary<string, List<string>>> alltotalReport = new ();
|
|
|
+ public Dictionary<string, Dictionary<string, List<string>>> alltotalReport = new();
|
|
|
|
|
|
public void Start()
|
|
|
{
|
|
|
MHRescueMissions?.ForEach(r => r.Reset());
|
|
|
XHRescueMissions?.ForEach(r => r.Reset());
|
|
|
-
|
|
|
+
|
|
|
MHRescueMissions?.ForEach(r => r.Start());
|
|
|
XHRescueMissions?.ForEach(r => r.Start());
|
|
|
ZCRescueMissions?.ForEach(r => r.Start());
|
|
@@ -32,17 +32,17 @@ public class TaskComponent : Component
|
|
|
//把totalReport保存到alltotalReport
|
|
|
foreach (var kv in totalReport)
|
|
|
{
|
|
|
- if(!alltotalReport.ContainsKey(kv.Key)) alltotalReport[kv.Key] = new Dictionary<string, List<string>>();
|
|
|
-
|
|
|
-
|
|
|
+ if (!alltotalReport.ContainsKey(kv.Key)) alltotalReport[kv.Key] = new Dictionary<string, List<string>>();
|
|
|
+
|
|
|
+
|
|
|
foreach (var kv2 in kv.Value)
|
|
|
{
|
|
|
- if(!alltotalReport[kv.Key].ContainsKey(kv2.Key)) alltotalReport[kv.Key][kv2.Key] = new List<string>();
|
|
|
-
|
|
|
+ if (!alltotalReport[kv.Key].ContainsKey(kv2.Key)) alltotalReport[kv.Key][kv2.Key] = new List<string>();
|
|
|
+
|
|
|
alltotalReport[kv.Key][kv2.Key].Add(kv2.Value);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 求一个平均值放到最后一位
|
|
|
foreach (var kv in alltotalReport)
|
|
|
{
|
|
@@ -51,21 +51,28 @@ public class TaskComponent : Component
|
|
|
var sum = 0f;
|
|
|
foreach (var value in kv2.Value)
|
|
|
{
|
|
|
- sum += float.Parse(value);
|
|
|
+ bool isfloat = float.TryParse(value, out float f);
|
|
|
+ if (isfloat)
|
|
|
+ sum += float.Parse(value);
|
|
|
+ else
|
|
|
+ sum = -1f;
|
|
|
}
|
|
|
- kv2.Value.Add((sum / kv2.Value.Count).ToString());
|
|
|
+ if (sum != -1f)
|
|
|
+ kv2.Value.Add((sum / kv2.Value.Count).ToString());
|
|
|
+ else
|
|
|
+ kv2.Value.Add("");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public void ReportAllSJ()
|
|
|
{
|
|
|
string data = DateTime.Now.ToString("yyyy-MM-dd");
|
|
|
string path = $"Reports/SJ/{data}";
|
|
|
- if(!Directory.Exists(path)) Directory.CreateDirectory(path);
|
|
|
+ if (!Directory.Exists(path)) Directory.CreateDirectory(path);
|
|
|
|
|
|
string totalPath = $"{path}/{"海上搜救任务总体指标报告"}.xls";
|
|
|
- DataTableExtensions.SaveToExcel(totalPath, alltotalReport,true);
|
|
|
+ DataTableExtensions.SaveToExcel(totalPath, alltotalReport, true);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -86,15 +93,15 @@ public class TaskComponentUpdateSystem : UpdateSystem<TaskComponent>
|
|
|
{
|
|
|
public override void Update(TaskComponent self)
|
|
|
{
|
|
|
- if(self.SeaSJRescueMissions.Count <= 0) return;
|
|
|
-
|
|
|
- if(self.SeaSJRescueMissions.All(m => m.IsOver))
|
|
|
- {
|
|
|
- self.SJAllTotalTaskPerformance.FillData(self.SeaSJRescueMissions);
|
|
|
- var report = self.SJAllTotalTaskPerformance.GetReport();
|
|
|
- self.SaveSJ(report);
|
|
|
- self.ReportAllSJ();
|
|
|
- self.SeaSJRescueMissions.Clear();
|
|
|
- }
|
|
|
+ if (self.SeaSJRescueMissions.Count <= 0) return;
|
|
|
+
|
|
|
+ if (self.SeaSJRescueMissions.All(m => m.IsOver))
|
|
|
+ {
|
|
|
+ self.SJAllTotalTaskPerformance.FillData(self.SeaSJRescueMissions);
|
|
|
+ var report = self.SJAllTotalTaskPerformance.GetReport();
|
|
|
+ self.SaveSJ(report);
|
|
|
+ self.ReportAllSJ();
|
|
|
+ self.SeaSJRescueMissions.Clear();
|
|
|
+ }
|
|
|
}
|
|
|
}
|