|
@@ -1,36 +1,32 @@
|
|
|
using KYFramework;
|
|
|
-using MongoDB.Bson;
|
|
|
using SimulationServer.Utils;
|
|
|
|
|
|
namespace SimulationServer;
|
|
|
|
|
|
-public class RescueMission : Entity
|
|
|
+public class MHRescueMission : Entity
|
|
|
{
|
|
|
public string MissionId;
|
|
|
public bool Success;
|
|
|
|
|
|
public double SimTime;
|
|
|
-
|
|
|
- public double Speed = 1000;
|
|
|
|
|
|
public double InitArea;
|
|
|
-
|
|
|
- public int ExecuteCount = 2;
|
|
|
private int currentExecuteCount = 1;
|
|
|
-
|
|
|
- public string MissionType;
|
|
|
+ public int ExecutionContext = 3;
|
|
|
|
|
|
|
|
|
public FireGround FireGround;
|
|
|
+ public double slope;
|
|
|
+ public double area;
|
|
|
|
|
|
public double tn;
|
|
|
+
|
|
|
+ public List<string> successes = new List<string>();
|
|
|
|
|
|
|
|
|
public List<AircraftMH> Aircrafts = new List<AircraftMH>();
|
|
|
public List<AircraftMHWithPersion> AircraftWithPersions = new List<AircraftMHWithPersion>();
|
|
|
- public List<AircraftXH> AircraftXHs = new List<AircraftXH>();
|
|
|
public List<AircraftSHJ> AircraftSHJs = new List<AircraftSHJ>();
|
|
|
- public List<AircraftZC> AircraftZCs = new List<AircraftZC>();
|
|
|
|
|
|
public bool IsRunning;
|
|
|
public Action End;
|
|
@@ -40,33 +36,32 @@ public class RescueMission : Entity
|
|
|
Dictionary<string,Dictionary<string,Dictionary<string,List<string>>>> singleReport =
|
|
|
new Dictionary<string, Dictionary<string, Dictionary<string, List<string>>>>();
|
|
|
|
|
|
-
|
|
|
-
|
|
|
- Dictionary<string,Dictionary<string,Dictionary<string,List<string>>>> singleXHReport =
|
|
|
- new Dictionary<string, Dictionary<string, Dictionary<string, List<string>>>>();
|
|
|
|
|
|
|
|
|
Dictionary<string, Dictionary<string, List<string>>> totalReport =
|
|
|
new Dictionary<string, Dictionary<string, List<string>>>();
|
|
|
|
|
|
-
|
|
|
- Dictionary<string, Dictionary<string, List<string>>> totalXhReport =
|
|
|
+ Dictionary<string, Dictionary<string, List<string>>> equipReport =
|
|
|
new Dictionary<string, Dictionary<string, List<string>>>();
|
|
|
|
|
|
- public void Start()
|
|
|
+ public void Reset()
|
|
|
{
|
|
|
- IsRunning = true;
|
|
|
SimTime = 0;
|
|
|
- Aircrafts?.ForEach(a => a.Start(FireGround, this));
|
|
|
- AircraftWithPersions?.ForEach(a => a.Start(FireGround,this));
|
|
|
+ area = 0;
|
|
|
aircrafts.Clear();
|
|
|
aircrafts.AddRange(Aircrafts);
|
|
|
aircrafts.AddRange(AircraftWithPersions);
|
|
|
-
|
|
|
- if (FireGround != null)
|
|
|
- {
|
|
|
- FireGround.countArea = new Fire.CountArea() { burnarea = InitArea};
|
|
|
- }
|
|
|
+ FireGround.countArea = new Fire.CountArea() { burnarea = InitArea};
|
|
|
+ Aircrafts?.ForEach(a => a.Reset());
|
|
|
+ AircraftWithPersions?.ForEach(a => a.Reset());
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public void Start()
|
|
|
+ {
|
|
|
+ IsRunning = true;
|
|
|
+ Aircrafts?.ForEach(a => a.Start());
|
|
|
+ AircraftWithPersions?.ForEach(a => a.Start());
|
|
|
Log.Info($"{MissionId} 任务开始!");
|
|
|
}
|
|
|
|
|
@@ -77,53 +72,28 @@ public class RescueMission : Entity
|
|
|
|
|
|
End?.Invoke();
|
|
|
|
|
|
- if(MissionType == "灭火")
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (currentExecuteCount > ExecutionContext)
|
|
|
{
|
|
|
- SaveMH();
|
|
|
- ReportMH();
|
|
|
+ return;
|
|
|
}
|
|
|
- else
|
|
|
+
|
|
|
+ if (currentExecuteCount < ExecutionContext)
|
|
|
{
|
|
|
- SaveXH();
|
|
|
- ReportXH();
|
|
|
+ SaveTotalMH();
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ if(currentExecuteCount == ExecutionContext)
|
|
|
+ {
|
|
|
+ SaveMH();
|
|
|
+ SaveTotalMH();
|
|
|
+ ReportMH();
|
|
|
+ }
|
|
|
+ this.Reset();
|
|
|
+ this.Start();
|
|
|
+ currentExecuteCount++;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -158,7 +128,7 @@ public class RescueMission : Entity
|
|
|
singleReport[aircraftMh.Name][kv.Key][kv2.Key].Add(kv2.Value);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
Dictionary<string, Dictionary<string, string>> taskReport = taskPerformance.GetReport();
|
|
|
foreach (var kv in taskReport)
|
|
|
{
|
|
@@ -182,7 +152,10 @@ public class RescueMission : Entity
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ }
|
|
|
+
|
|
|
+ public void SaveTotalMH()
|
|
|
+ {
|
|
|
var totalPerformance = GetComponent<TotalTaskPerformanceComponent>();
|
|
|
totalPerformance.FillData();
|
|
|
var totalPerformanceReport = totalPerformance.GetReport();
|
|
@@ -193,11 +166,20 @@ public class RescueMission : Entity
|
|
|
foreach (var kv2 in kv.Value)
|
|
|
{
|
|
|
if (!totalReport[kv.Key].ContainsKey(kv2.Key)) totalReport[kv.Key][kv2.Key] = new List<string>();
|
|
|
- totalReport[kv.Key][kv2.Key].Add(kv2.Value);
|
|
|
+
|
|
|
+ if(kv2.Key == "任务成功率")
|
|
|
+ {
|
|
|
+ successes.Add(kv2.Value);
|
|
|
+
|
|
|
+ totalReport[kv.Key][kv2.Key].Add((getSuccessRate() * 100) + "%");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ totalReport[kv.Key][kv2.Key].Add(kv2.Value);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
var TotalEconomical = GetComponent<TotalEconomicalComponent>();
|
|
|
TotalEconomical.FillData();
|
|
|
var totalEconomicalReport = TotalEconomical.GetReport();
|
|
@@ -210,104 +192,60 @@ public class RescueMission : Entity
|
|
|
totalReport[kv.Key][kv2.Key].Add(kv2.Value);
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- public void SaveXH()
|
|
|
- {
|
|
|
- foreach (AircraftXH aircraftXh in AircraftXHs)
|
|
|
+
|
|
|
+ var TotalEquipment = GetComponent<EquipmentComponent>();
|
|
|
+ TotalEquipment.FillData();
|
|
|
+ var totalEquipmentReport = TotalEquipment.GetReport();
|
|
|
+ foreach (var kv in totalEquipmentReport)
|
|
|
{
|
|
|
- var staticCapacity = aircraftXh.GetComponent<XHStaticCapacityComponent>();
|
|
|
- var economical = aircraftXh.GetComponent<XHEconomicalComponent>();
|
|
|
-
|
|
|
- staticCapacity.FillData(aircraftXh.Db);
|
|
|
- economical.FillData(aircraftXh.Db);
|
|
|
-
|
|
|
- if (!singleReport.ContainsKey(aircraftXh.Type))
|
|
|
- {
|
|
|
- singleReport[aircraftXh.Name] = new Dictionary<string, Dictionary<string, List<string>>>();
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- Dictionary<string, Dictionary<string, string>> staticReport = staticCapacity.GetReport();
|
|
|
- foreach (var kv in staticReport)
|
|
|
- {
|
|
|
- if(!singleReport[aircraftXh.Name].ContainsKey(kv.Key)) singleReport[aircraftXh.Name][kv.Key] = new Dictionary<string, List<string>>();
|
|
|
- foreach (var kv2 in kv.Value)
|
|
|
- {
|
|
|
- if (!singleReport[aircraftXh.Name][kv.Key].ContainsKey(kv2.Key)) singleReport[aircraftXh.Name][kv.Key][kv2.Key] = new List<string>();
|
|
|
- singleReport[aircraftXh.Name][kv.Key][kv2.Key].Add(kv2.Value);
|
|
|
- }
|
|
|
- }
|
|
|
- Dictionary<string, Dictionary<string, string>> economicalReport = economical.GetReport();
|
|
|
- foreach (var kv in economicalReport)
|
|
|
+ if(!equipReport.ContainsKey(kv.Key)) equipReport[kv.Key] = new Dictionary<string, List<string>>();
|
|
|
+ foreach (var kv2 in kv.Value)
|
|
|
{
|
|
|
- if(!singleReport[aircraftXh.Name].ContainsKey(kv.Key)) singleReport[aircraftXh.Name][kv.Key] = new Dictionary<string, List<string>>();
|
|
|
- foreach (var kv2 in kv.Value)
|
|
|
- {
|
|
|
- if (!singleReport[aircraftXh.Name][kv.Key].ContainsKey(kv2.Key)) singleReport[aircraftXh.Name][kv.Key][kv2.Key] = new List<string>();
|
|
|
- singleReport[aircraftXh.Name][kv.Key][kv2.Key].Add(kv2.Value);
|
|
|
- }
|
|
|
+ if (!equipReport[kv.Key].ContainsKey(kv2.Key)) equipReport[kv.Key][kv2.Key] = new List<string>();
|
|
|
+ equipReport[kv.Key][kv2.Key].Add(kv2.Value);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- var totalPerformance = GetComponent<XHTotalTaskPerformanceComponent>();
|
|
|
- totalPerformance.FillData();
|
|
|
- var totalPerformanceReport = totalPerformance.GetReport();
|
|
|
- foreach (var kv in totalPerformanceReport)
|
|
|
+ }
|
|
|
+
|
|
|
+ public float getSuccessRate()
|
|
|
+ {
|
|
|
+ int count = 0;
|
|
|
+ foreach (string success in successes)
|
|
|
{
|
|
|
- if(!totalXhReport.ContainsKey(kv.Key)) totalXhReport[kv.Key] = new Dictionary<string, List<string>>();
|
|
|
- foreach (var kv2 in kv.Value)
|
|
|
+ if(success == "成功")
|
|
|
{
|
|
|
- if (!totalXhReport[kv.Key].ContainsKey(kv2.Key)) totalXhReport[kv.Key][kv2.Key] = new List<string>();
|
|
|
- totalXhReport[kv.Key][kv2.Key].Add(kv2.Value);
|
|
|
+ count++;
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
+ return count / successes.Count;
|
|
|
+ }
|
|
|
|
|
|
public void ReportMH()
|
|
|
{
|
|
|
string data = DateTime.Now.ToString("yyyy-MM-dd");
|
|
|
-
|
|
|
string path = $"Reports/MH/{data}/{MissionId}";
|
|
|
-
|
|
|
if(!Directory.Exists(path)) Directory.CreateDirectory(path);
|
|
|
-
|
|
|
foreach (var kv in singleReport)
|
|
|
{
|
|
|
string filePath = $"{path}/{kv.Key}灭火任务单机指标报告.xls";
|
|
|
DataTableExtensions.SaveToExcel(filePath, kv.Value);
|
|
|
}
|
|
|
string totalPath = $"{path}/{"灭火任务总体指标报告"}.xls";
|
|
|
-
|
|
|
-
|
|
|
DataTableExtensions.SaveToExcel(totalPath, totalReport);
|
|
|
- }
|
|
|
-
|
|
|
- public void ReportXH()
|
|
|
- {
|
|
|
- string data = DateTime.Now.ToString("yyyy-MM-dd");
|
|
|
- string path = $"Reports/XH/{data}/{MissionId}";
|
|
|
- if(!Directory.Exists(path)) Directory.CreateDirectory(path);
|
|
|
- foreach (var kv in singleReport)
|
|
|
- {
|
|
|
- string filePath = $"{path}/{kv.Key}巡护任务单机指标报告.xls";
|
|
|
- DataTableExtensions.SaveToExcel(filePath, kv.Value);
|
|
|
- }
|
|
|
- string totalPath = $"{path}/{"巡护任务总体指标报告"}.xls";
|
|
|
- DataTableExtensions.SaveToExcel(totalPath, totalXhReport);
|
|
|
+
|
|
|
+ string equicPath = $"{path}/{"装备体系评估报告"}.xls";
|
|
|
+ DataTableExtensions.SaveToExcel(equicPath, equipReport);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
[ObjectSystem]
|
|
|
-public class RescueMissionUpdateSystem : UpdateSystem<RescueMission>
|
|
|
+public class RescueMissionUpdateSystem : UpdateSystem<MHRescueMission>
|
|
|
{
|
|
|
- public override void Update(RescueMission self)
|
|
|
+ public override void Update(MHRescueMission self)
|
|
|
{
|
|
|
if(!self.IsRunning) return;
|
|
|
- if(self.FireGround == null) return;
|
|
|
+
|
|
|
if (self.FireGround.countArea.burnarea <= 0)
|
|
|
{
|
|
|
self.Success = true;
|
|
@@ -317,8 +255,6 @@ public class RescueMissionUpdateSystem : UpdateSystem<RescueMission>
|
|
|
|
|
|
self.aircrafts.Sort((a, b) => a.T.CompareTo(b.T));
|
|
|
self.aircrafts.ForEach(a => a.Update(self.SimTime));
|
|
|
-
|
|
|
- self.AircraftXHs?.ForEach(a => a.Update());
|
|
|
- self.SimTime += 1 * self.Speed;
|
|
|
+ self.SimTime += 1 * TaskComponent.Speed;
|
|
|
}
|
|
|
}
|