Browse Source

修改陆上搜寻输出表格功能

liyang 7 months ago
parent
commit
c459eb61cb

BIN
Models/SimulationCommon/dll/BHJD.DEMdll.dll


+ 94 - 25
SimulationServer/Component/SJAllTotalTaskPerformance.cs

@@ -12,12 +12,15 @@ public class SJAllTotalTaskPerformance
     public string 海情覆盖率;
     public string 任务是否成功;
     public string 人员存活率;
+    public string 环境覆盖率;
 }
 
 public class SJAllTotalTaskPerformanceComponent
 {
-    public SJAllTotalTaskPerformance SJAllTotalTaskPerformance = new SJAllTotalTaskPerformance();
-    public int index;
+    public SJAllTotalTaskPerformance SSJAllTotalTaskPerformance = new SJAllTotalTaskPerformance();
+    public SJAllTotalTaskPerformance LSJAllTotalTaskPerformance = new SJAllTotalTaskPerformance();
+    public int sIndex;
+    public int lIndex;
 
     public void FillData(List<SeaSJRescueMission> missions)
     {
@@ -45,27 +48,76 @@ public class SJAllTotalTaskPerformanceComponent
             //}
             foreach (var item in mhRescueMission.aircraftSJDatas)
             {
-                识别成功率 += float.Parse(item.Value["识别成功率"][index]);
-                if (任务准备时间 < float.Parse(item.Value["任务准备时间"][index]))
-                    任务准备时间 = float.Parse(item.Value["任务准备时间"][index]);
-                平均搜索时间 += float.Parse(item.Value["平均搜索时间"][index]);
-                总飞行时间 += float.Parse(item.Value["总飞行时间"][index]);
-                人员存活率 += float.Parse(item.Value["人员存活率"][index]);
+                识别成功率 += float.Parse(item.Value["识别成功率"][sIndex]);
+                if (任务准备时间 < float.Parse(item.Value["任务准备时间"][sIndex]))
+                    任务准备时间 = float.Parse(item.Value["任务准备时间"][sIndex]);
+                平均搜索时间 += float.Parse(item.Value["平均搜索时间"][sIndex]);
+                总飞行时间 += float.Parse(item.Value["总飞行时间"][sIndex]);
+                人员存活率 += float.Parse(item.Value["人员存活率"][sIndex]);
                 aircreftCount++;
             }
 
         }
         if (人员存活率 != 0)
             任务是否成功 = 1;
-        SJAllTotalTaskPerformance.识别成功率 = (识别成功率 / aircreftCount).ToString();
-        SJAllTotalTaskPerformance.任务准备时间 = 任务准备时间.ToString();
-        SJAllTotalTaskPerformance.平均搜索时间 = (平均搜索时间 / aircreftCount).ToString();
-        SJAllTotalTaskPerformance.平均救助时间 = 5.ToString();
-        SJAllTotalTaskPerformance.总飞行时间 = 总飞行时间.ToString();
-        SJAllTotalTaskPerformance.海情覆盖率 = "0.6".ToString();//"60%"
-        SJAllTotalTaskPerformance.任务是否成功 = 任务是否成功.ToString();
-        SJAllTotalTaskPerformance.人员存活率 = (人员存活率 / aircreftCount).ToString();
-        index++;
+        SSJAllTotalTaskPerformance.识别成功率 = (识别成功率 / aircreftCount).ToString();
+        SSJAllTotalTaskPerformance.任务准备时间 = 任务准备时间.ToString();
+        SSJAllTotalTaskPerformance.平均搜索时间 = (平均搜索时间 / aircreftCount).ToString();
+        SSJAllTotalTaskPerformance.平均救助时间 = 5.ToString();
+        SSJAllTotalTaskPerformance.总飞行时间 = 总飞行时间.ToString();
+        SSJAllTotalTaskPerformance.海情覆盖率 = "0.6".ToString();//"60%"
+        SSJAllTotalTaskPerformance.任务是否成功 = 任务是否成功.ToString();
+        SSJAllTotalTaskPerformance.人员存活率 = (人员存活率 / aircreftCount).ToString();
+        sIndex++;
+    }
+
+    public void FillData1(List<LandSJRescueMission> missions)
+    {
+        double 任务准备时间 = 0;
+        double 平均搜索时间 = 0;
+        double 总飞行时间 = 0;
+        double 人员存活率 = 0;
+        double 任务是否成功 = 0;
+        float 识别成功率 = 0f;
+
+
+        double aircreftCount = 0;
+        foreach (LandSJRescueMission mhRescueMission in missions)
+        {
+            //foreach (var aircraft in mhRescueMission.aircrafts)
+            //{
+            //    if (aircraft.isseePerson)
+            //        识别成功率 += 1f;
+            //    if (任务准备时间 < aircraft.TaskReadyTime)
+            //        任务准备时间 = aircraft.TaskReadyTime;
+            //    平均搜索时间 += aircraft.SearchTime;
+            //    总飞行时间 += aircraft.TotalTime;
+            //    人员存活率 += aircraft.Success ? 1 : 0;
+            //    aircreftCount++;
+            //}
+            foreach (var item in mhRescueMission.aircraftSJDatas)
+            {
+                识别成功率 += float.Parse(item.Value["识别成功率"][lIndex]);
+                if (任务准备时间 < float.Parse(item.Value["任务准备时间"][lIndex]))
+                    任务准备时间 = float.Parse(item.Value["任务准备时间"][lIndex]);
+                平均搜索时间 += float.Parse(item.Value["平均搜索时间"][lIndex]);
+                总飞行时间 += float.Parse(item.Value["总飞行时间"][lIndex]);
+                人员存活率 += float.Parse(item.Value["人员存活率"][lIndex]);
+                aircreftCount++;
+            }
+
+        }
+        if (人员存活率 != 0)
+            任务是否成功 = 1;
+        LSJAllTotalTaskPerformance.识别成功率 = (识别成功率 / aircreftCount).ToString();
+        LSJAllTotalTaskPerformance.任务准备时间 = 任务准备时间.ToString();
+        LSJAllTotalTaskPerformance.平均搜索时间 = (平均搜索时间 / aircreftCount).ToString();
+        LSJAllTotalTaskPerformance.平均救助时间 = 5.ToString();
+        LSJAllTotalTaskPerformance.总飞行时间 = 总飞行时间.ToString();
+        LSJAllTotalTaskPerformance.环境覆盖率 = "0.6".ToString();//"60%"
+        LSJAllTotalTaskPerformance.任务是否成功 = 任务是否成功.ToString();
+        LSJAllTotalTaskPerformance.人员存活率 = (人员存活率 / aircreftCount).ToString();
+        lIndex++;
     }
 
     public Dictionary<string, Dictionary<string, string>> GetReport()
@@ -73,14 +125,31 @@ public class SJAllTotalTaskPerformanceComponent
         Dictionary<string, Dictionary<string, string>> report = new Dictionary<string, Dictionary<string, string>>();
         report["总任务表现"] = new Dictionary<string, string>
         {
-            { "识别成功率", SJAllTotalTaskPerformance.识别成功率.ToString() },
-            { "任务准备时间", SJAllTotalTaskPerformance.任务准备时间.ToString() },
-            { "平均搜索时间", SJAllTotalTaskPerformance.平均搜索时间.ToString() },
-            { "平均救助时间", SJAllTotalTaskPerformance.平均救助时间.ToString() },
-            { "总飞行时间", SJAllTotalTaskPerformance.总飞行时间.ToString() },
-            { "海情覆盖率", SJAllTotalTaskPerformance.海情覆盖率.ToString() },
-            { "任务是否成功", SJAllTotalTaskPerformance.任务是否成功.ToString() },
-            { "人员存活率", SJAllTotalTaskPerformance.人员存活率.ToString() }
+            { "识别成功率", SSJAllTotalTaskPerformance.识别成功率.ToString() },
+            { "任务准备时间", SSJAllTotalTaskPerformance.任务准备时间.ToString() },
+            { "平均搜索时间", SSJAllTotalTaskPerformance.平均搜索时间.ToString() },
+            { "平均救助时间", SSJAllTotalTaskPerformance.平均救助时间.ToString() },
+            { "总飞行时间", SSJAllTotalTaskPerformance.总飞行时间.ToString() },
+            { "海情覆盖率", SSJAllTotalTaskPerformance.海情覆盖率.ToString() },
+            { "任务是否成功", SSJAllTotalTaskPerformance.任务是否成功.ToString() },
+            { "人员存活率", SSJAllTotalTaskPerformance.人员存活率.ToString() }
+        };
+        return report;
+    }
+
+    public Dictionary<string, Dictionary<string, string>> GetReport1()
+    {
+        Dictionary<string, Dictionary<string, string>> report = new Dictionary<string, Dictionary<string, string>>();
+        report["总任务表现"] = new Dictionary<string, string>
+        {
+            { "识别成功率", LSJAllTotalTaskPerformance.识别成功率.ToString() },
+            { "任务准备时间", LSJAllTotalTaskPerformance.任务准备时间.ToString() },
+            { "平均搜索时间", LSJAllTotalTaskPerformance.平均搜索时间.ToString() },
+            { "平均救助时间", LSJAllTotalTaskPerformance.平均救助时间.ToString() },
+            { "总飞行时间", LSJAllTotalTaskPerformance.总飞行时间.ToString() },
+            { "环境覆盖率", LSJAllTotalTaskPerformance.海情覆盖率.ToString() },
+            { "任务是否成功", LSJAllTotalTaskPerformance.任务是否成功.ToString() },
+            { "人员存活率", LSJAllTotalTaskPerformance.人员存活率.ToString() }
         };
         return report;
     }

+ 59 - 4
SimulationServer/Component/SJStaticCapacityComponent.cs

@@ -41,7 +41,10 @@ public class SJStaticCapacity
     public string 搜救相对耗油率 = String.Empty;
     //最大飞行时间
     public string 有效探测距离 = String.Empty;
+    //最大起降高度
+    public string 最大起降高度 = String.Empty;
 }
+
 public class SJStaticCapacityComponent : Component
 {
     public SJStaticCapacity SJStaticCapacity = new SJStaticCapacity();
@@ -49,8 +52,8 @@ public class SJStaticCapacityComponent : Component
     public void FillData(AircraftDB db)
     {
         var aircraft = GetParent<AircraftSJ>();
-        
-        SJStaticCapacity.初次出动准备时间 =  aircraft.TaskReadyTime.ToString();
+
+        SJStaticCapacity.初次出动准备时间 = aircraft.TaskReadyTime.ToString();
         SJStaticCapacity.再次补给时间 = db.fjysj == null ? "0" : db.fjysj.ToString();
         SJStaticCapacity.舱内载荷 = db.fzdnz == null ? "0" : db.fzdnz.ToString();
         //SJStaticCapacity.机舱容量 = db.fjcrll == null ? "0" : db.fjcrll.ToString();
@@ -61,7 +64,7 @@ public class SJStaticCapacityComponent : Component
         SJStaticCapacity.抗风等级 = "八级";
         //SJStaticCapacity.抗浪等级 = db.fkldj == null ? "0" : db.fkldj.ToString();
         SJStaticCapacity.起降距离 = db.fjjcdc == null ? "0" : db.fjjcdc.ToString();
-        SJStaticCapacity.夜间作业能力 =0.ToString();
+        SJStaticCapacity.夜间作业能力 = 0.ToString();
         SJStaticCapacity.仪表飞行能力 = 0.ToString();
         SJStaticCapacity.可靠性 = 0.ToString();
         //SJStaticCapacity.航程 = db.fhc == null ? "0" : db.fhc.ToString();
@@ -70,6 +73,31 @@ public class SJStaticCapacityComponent : Component
         SJStaticCapacity.有效探测距离 = 2.ToString();
     }
 
+    public void FillData1(AircraftDB db)
+    {
+        var aircraft = GetParent<AircraftLandSJ>();
+
+        SJStaticCapacity.初次出动准备时间 = "30";
+        SJStaticCapacity.再次补给时间 = "5";
+        SJStaticCapacity.舱内载荷 = db.fzdnz == null ? "0" : db.fzdnz.ToString();
+        //SJStaticCapacity.机舱容量 = db.fjcrll == null ? "0" : db.fjcrll.ToString();
+        SJStaticCapacity.最大平飞速度 = db.fzdss == null ? "0" : db.fzdss.ToString();
+        SJStaticCapacity.巡航速度 = db.fzdss == null ? "0" : db.fzdss.ToString();
+        //SJStaticCapacity.搜救速度 = db.fsjfxsd == null ? "0" : db.fsjfxsd.ToString();
+        //SJStaticCapacity.单人救助时间 = db.fdrjzsj == null ? "0" : db.fdrjzsj.ToString();
+        SJStaticCapacity.抗风等级 = "八级";
+        SJStaticCapacity.最大起降高度 = "";
+        //SJStaticCapacity.抗浪等级 = db.fkldj == null ? "0" : db.fkldj.ToString();
+        //SJStaticCapacity.起降距离 = db.fjjcdc == null ? "0" : db.fjjcdc.ToString();
+        SJStaticCapacity.夜间作业能力 = 0.ToString();
+        SJStaticCapacity.仪表飞行能力 = 0.ToString();
+        SJStaticCapacity.可靠性 = "0.9";
+        //SJStaticCapacity.航程 = db.fhc == null ? "0" : db.fhc.ToString();
+        SJStaticCapacity.悬停相对耗油率 = FXJHGenerate.GetHoverFuelConsumptionRate(aircraft.FlightPlanEditor, 50).ToString();
+        SJStaticCapacity.搜救相对耗油率 = FXJHGenerate.GetCruisingVelocity(aircraft.FlightPlanEditor, 50).ToString();
+        SJStaticCapacity.有效探测距离 = 2.ToString();
+    }
+
 
     public Dictionary<string, Dictionary<string, string>> GetReport()
     {
@@ -98,5 +126,32 @@ public class SJStaticCapacityComponent : Component
         };
         return report;
     }
-    
+
+    public Dictionary<string, Dictionary<string, string>> GetReport1()
+    {
+        Dictionary<string, Dictionary<string, string>> report = new Dictionary<string, Dictionary<string, string>>();
+        report["静态能力"] = new Dictionary<string, string>
+        {
+            { "初次出动准备时间/s", SJStaticCapacity.初次出动准备时间.ToString() },
+            { "再次补给时间/s", SJStaticCapacity.再次补给时间.ToString() },
+            { "舱内载荷/kg", SJStaticCapacity.舱内载荷.ToString() },
+            { "机舱容量/kg", SJStaticCapacity.机舱容量.ToString() },
+            { "最大平飞速度/km/h", SJStaticCapacity.最大平飞速度.ToString() },
+            { "巡航速度/km/h", SJStaticCapacity.巡航速度.ToString() },
+            { "搜救速度/km/h", SJStaticCapacity.搜救速度.ToString() },
+            { "单人救助时间/s", SJStaticCapacity.单人救助时间.ToString() },
+            { "抗风等级", SJStaticCapacity.抗风等级.ToString() },
+            { "最大起降高度", SJStaticCapacity.最大起降高度.ToString() },
+            { "夜间作业能力", SJStaticCapacity.夜间作业能力.ToString() },
+            { "仪表飞行能力", SJStaticCapacity.仪表飞行能力.ToString() },
+            { "可靠性", SJStaticCapacity.可靠性.ToString() },
+            { "航程/km", SJStaticCapacity.航程.ToString() },
+            { "悬停相对耗油率", SJStaticCapacity.悬停相对耗油率.ToString() },
+            { "搜救相对耗油率", SJStaticCapacity.搜救相对耗油率.ToString() },
+            { "有效探测距离/m", SJStaticCapacity.有效探测距离.ToString() }
+
+        };
+        return report;
+    }
+
 }

+ 111 - 26
SimulationServer/Component/TaskComponent.cs

@@ -14,15 +14,19 @@ public class TaskComponent : Component
     public List<SeaSJRescueMission> SeaSJRescueMissions;
     public List<LandSJRescueMission> LandSJRescueMissions;
 
-    public SJAllTotalTaskPerformanceComponent SJAllTotalTaskPerformance = new SJAllTotalTaskPerformanceComponent();
-    public Dictionary<string, Dictionary<string, List<string>>> alltotalReport = new();
+    public SJAllTotalTaskPerformanceComponent SSJAllTotalTaskPerformance = new SJAllTotalTaskPerformanceComponent();
+    public Dictionary<string, Dictionary<string, List<string>>> alltotalReportSea = new();
+    public Dictionary<string, Dictionary<string, List<string>>> alltotalReportLand = new();
     // <sheet,<指标名,值列表>>
-    public Dictionary<string, Dictionary<string, List<string>>> totalReport = new();
+    public Dictionary<string, Dictionary<string, List<string>>> totalReportSea = new();
+    public Dictionary<string, Dictionary<string, List<string>>> totalReportLand = new();
 
-    private int currentExecuteCount = 1;
+    private int currentSeaExecuteCount = 1;
+    private int currentLandExecuteCount = 1;
     public int ExecutionContext = 0;
 
-    public int successCount = 0;
+    public int seaSuccessCount = 0;
+    public int landSuccessCount = 0;
 
     public void Start()
     {
@@ -36,26 +40,26 @@ public class TaskComponent : Component
         LandSJRescueMissions?.ForEach(r => r.Start());
     }
 
-    public void SaveSJ(Dictionary<string, Dictionary<string, string>> totalReport)
+    public void SaveSeaSJ(Dictionary<string, Dictionary<string, string>> totalReport)
     {
         //把totalReport保存到alltotalReport
         foreach (var kv in totalReport)
         {
-            if (!alltotalReport.ContainsKey(kv.Key)) alltotalReport[kv.Key] = new Dictionary<string, List<string>>();
+            if (!alltotalReportSea.ContainsKey(kv.Key)) alltotalReportSea[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 (!alltotalReportSea[kv.Key].ContainsKey(kv2.Key)) alltotalReportSea[kv.Key][kv2.Key] = new List<string>();
 
-                alltotalReport[kv.Key][kv2.Key].Add(kv2.Value);
+                alltotalReportSea[kv.Key][kv2.Key].Add(kv2.Value);
             }
         }
 
-        if (currentExecuteCount == ExecutionContext)
+        if (currentSeaExecuteCount == ExecutionContext)
         {
             // 求一个平均值放到最后一位
-            foreach (var kv in alltotalReport)
+            foreach (var kv in alltotalReportSea)
             {
                 foreach (var kv2 in kv.Value)
                 {
@@ -76,28 +80,92 @@ public class TaskComponent : Component
             }
         }
 
-        currentExecuteCount++;
+        currentSeaExecuteCount++;
     }
 
-    public void ReportAllSJ()
+    public void SaveLandSJ(Dictionary<string, Dictionary<string, string>> totalReport)
+    {
+        //把totalReport保存到alltotalReport
+        foreach (var kv in totalReport)
+        {
+            if (!alltotalReportLand.ContainsKey(kv.Key)) alltotalReportLand[kv.Key] = new Dictionary<string, List<string>>();
+
+
+            foreach (var kv2 in kv.Value)
+            {
+                if (!alltotalReportLand[kv.Key].ContainsKey(kv2.Key)) alltotalReportLand[kv.Key][kv2.Key] = new List<string>();
+
+                alltotalReportLand[kv.Key][kv2.Key].Add(kv2.Value);
+            }
+        }
+
+        if (currentLandExecuteCount == ExecutionContext)
+        {
+            // 求一个平均值放到最后一位
+            foreach (var kv in alltotalReportLand)
+            {
+                foreach (var kv2 in kv.Value)
+                {
+                    var sum = 0f;
+                    foreach (var value in kv2.Value)
+                    {
+                        bool isfloat = float.TryParse(value, out float f);
+                        if (isfloat)
+                            sum += float.Parse(value);
+                        else
+                            sum = -1f;
+                    }
+                    if (sum != -1f)
+                        kv2.Value.Add((sum / kv2.Value.Count).ToString());
+                    else
+                        kv2.Value.Add("");
+                }
+            }
+        }
+
+        currentLandExecuteCount++;
+    }
+
+    public void ReportAllSJSea()
     {
         string data = DateTime.Now.ToString("yyyy-MM-dd");
-        string path = $"Reports/SJ/{data}";
+        string path = $"Reports/SSJ/{data}";
         if (!Directory.Exists(path)) Directory.CreateDirectory(path);
 
         string totalPath = $"{path}/{"海上搜救任务总体指标报告"}.xls";
-        DataTableExtensions.SaveToExcel(totalPath, alltotalReport, true);
+        DataTableExtensions.SaveToExcel(totalPath, alltotalReportSea, true);
+
+
+        string totalPath1 = $"{path}/{"搜救任务总体指标报告"}.xls";
+        DataTableExtensions.SaveToExcel(totalPath1, totalReportSea);
+    }
+
+    public void ReportAllSJLand()
+    {
+        string data = DateTime.Now.ToString("yyyy-MM-dd");
+        string path = $"Reports/LSX/{data}";
+        if (!Directory.Exists(path)) Directory.CreateDirectory(path);
+
+        string totalPath = $"{path}/{"陆上搜寻任务总体指标报告"}.xls";
+        DataTableExtensions.SaveToExcel(totalPath, alltotalReportLand, true);
 
 
         string totalPath1 = $"{path}/{"搜救任务总体指标报告"}.xls";
-        DataTableExtensions.SaveToExcel(totalPath1, totalReport);
+        DataTableExtensions.SaveToExcel(totalPath1, totalReportLand);
     }
 
-    public void SaveTotalMH()
+    public void SaveTotalMHSea()
     {
-        if (!totalReport.ContainsKey("总任务表现")) totalReport["总任务表现"] = new Dictionary<string, List<string>>();
-        if (!totalReport["总任务表现"].ContainsKey("任务成功率")) totalReport["总任务表现"]["任务成功率"] = new List<string>();
-        totalReport["总任务表现"]["任务成功率"].Add((successCount * 1f / ExecutionContext).ToString());
+        if (!totalReportSea.ContainsKey("总任务表现")) totalReportSea["总任务表现"] = new Dictionary<string, List<string>>();
+        if (!totalReportSea["总任务表现"].ContainsKey("任务成功率")) totalReportSea["总任务表现"]["任务成功率"] = new List<string>();
+        totalReportSea["总任务表现"]["任务成功率"].Add((seaSuccessCount * 1f / ExecutionContext).ToString());
+    }
+
+    public void SaveTotalMHLand()
+    {
+        if (!totalReportLand.ContainsKey("总任务表现")) totalReportLand["总任务表现"] = new Dictionary<string, List<string>>();
+        if (!totalReportLand["总任务表现"].ContainsKey("任务成功率")) totalReportLand["总任务表现"]["任务成功率"] = new List<string>();
+        totalReportLand["总任务表现"]["任务成功率"].Add((landSuccessCount * 1f / ExecutionContext).ToString());
     }
 }
 
@@ -125,15 +193,32 @@ public class TaskComponentUpdateSystem : UpdateSystem<TaskComponent>
         {
             for (int i = 0; i < self.ExecutionContext; i++)
             {
-                self.SJAllTotalTaskPerformance.FillData(self.SeaSJRescueMissions);
-                var report = self.SJAllTotalTaskPerformance.GetReport();
+                self.SSJAllTotalTaskPerformance.FillData(self.SeaSJRescueMissions);
+                var report = self.SSJAllTotalTaskPerformance.GetReport();
                 if (report["总任务表现"]["任务是否成功"] == "1")
-                    self.successCount++;
-                self.SaveSJ(report);
+                    self.seaSuccessCount++;
+                self.SaveSeaSJ(report);
             }
-            self.SaveTotalMH();
-            self.ReportAllSJ();
+            self.SaveTotalMHSea();
+            self.ReportAllSJSea();
             self.SeaSJRescueMissions.Clear();
         }
+
+        if (self.LandSJRescueMissions.Count <= 0) return;
+
+        if (self.LandSJRescueMissions.All(m => m.IsOver))
+        {
+            for (int i = 0; i < self.ExecutionContext; i++)
+            {
+                self.SSJAllTotalTaskPerformance.FillData1(self.LandSJRescueMissions);
+                var report = self.SSJAllTotalTaskPerformance.GetReport1();
+                if (report["总任务表现"]["任务是否成功"] == "1")
+                    self.landSuccessCount++;
+                self.SaveLandSJ(report);
+            }
+            self.SaveTotalMHLand();
+            self.ReportAllSJLand();
+            self.LandSJRescueMissions.Clear();
+        }
     }
 }

+ 24 - 5
SimulationServer/Entity/AircraftLandSJ.cs

@@ -8,6 +8,7 @@ using Unity.Mathematics;
 using Point = SimulationCommon.Point;
 using Random = System.Random;
 using QuYuSaoMiao;
+using System.Threading;
 
 namespace SimulationServer;
 
@@ -22,11 +23,14 @@ public class AircraftLandSJ : AircraftEntity
 
     public MissionEndPoint MissionEndPoint;
     public SearchMissionMode SearchMissionMode;
+    public bool Success = true; //本目标搜救是否成功
 
     public override void Reset()
     {
         base.Reset();
         IsOver = false;
+        isseePerson = false;
+        Success = true;
         SearchTime = 0;
         TotalTime = 0;
     }
@@ -89,21 +93,36 @@ public class AircraftLandSJ : AircraftEntity
                     currentLocation.CurrentLat,
                     targetPoint.y);
                 Log.Info("距离:====================" + distance);
+
+                //====================================================
+                Text_readNC text_ReadNC = new Text_readNC();
+                text_ReadNC.GetNCData();
+                text_ReadNC.GetWaveHighData();
+                var nCread = text_ReadNC.windNCread;
+                var wind = SeaSJ.GetWindVelocityFromAPI(nCread, currentLocation.CurrentLat, currentLocation.CurrentLon,temptime);
+
+
+                var windSpeed = Math.Sqrt(wind[0] * wind[0] + wind[1] * wind[1]);
+
+                var waveHigh = SeaSJ.GetWaveHeightFromAPI(nCread, currentLocation.CurrentLon,
+                    currentLocation.CurrentLat, temptime);
+
+                //====================================================
                 if (distance < 20)
                 {
                     //TODO 和学生对接确认, 发现概率算法
-                    //probability = helper.getProbability(aricraftPoint, targetPoint, currentLocation.CurrentCourse,
-                    //    windSpeed, waveHigh, "落水人员", "海上"); // 计算发现概率,需要其他模型输入 // 计算发现概率,需要其他模型输入
+                    probability = helper.getProbability(aricraftPoint, targetPoint, currentLocation.CurrentCourse,
+                        windSpeed, waveHigh, "落水人员", "海上"); // 计算发现概率,需要其他模型输入 // 计算发现概率,需要其他模型输入
                 }
 
 
-                //finalProbability *= (1 - probability);
+                //finalProbability *= (1 - probability); 
 
                 Console.WriteLine(
                     $"海上任务:{taskContent.missionInformation.MissionName} 机型: {AircraftId} 当前时间:{temptime},当前位置:{currentLocation.CurrentLon},{currentLocation.CurrentLat},{currentLocation.CurrentHei},概率:{probability},最终概率:{1 - finalProbability},是否看到落水人员:{isseePerson}");
 
                 double randomValue = random.NextDouble(); // 生成随机数比较概率
-                if (randomValue < (probability))
+                if (randomValue < probability) // 1 - finalProbability
                 {
                     isseePerson = true;
                     this.isseePerson = true;
@@ -123,7 +142,7 @@ public class AircraftLandSJ : AircraftEntity
             Console.WriteLine(
                 $"海上任务:{taskContent.missionInformation.MissionName} 机型: {AircraftId} 当前时间:{temptime},当前位置:{currentLocation.CurrentLon},{currentLocation.CurrentLat},{currentLocation.CurrentHei},概率:{probability},最终概率:{1 - finalProbability},是否看到落水人员:{isseePerson}");
 
-            //finalProbability = 1 - finalProbability;
+            //finalProbability = 1 - finalProbability; 
 
             if (fireIndex != -1)
             {

+ 3 - 3
SimulationServer/Entity/AircraftSJ.cs

@@ -204,13 +204,13 @@ public class AircraftSJ : AircraftEntity
                         windSpeed, waveHigh, "落水人员", "海上"); // 计算发现概率,需要其他模型输入 // 计算发现概率,需要其他模型输入
                 }
 
-                finalProbability *= (1 - probability);
+                finalProbability *= (1 - probability); //
 
                 Console.WriteLine(
                     $"海上任务:{taskContent.missionInformation.MissionName} 机型: {AircraftId} 当前时间:{temptime},当前位置:{currentLocation.CurrentLon},{currentLocation.CurrentLat},{currentLocation.CurrentHei},概率:{probability},最终概率:{1 - finalProbability},是否看到落水人员:{isseePerson}");
 
                 double randomValue = random.NextDouble(); // 生成随机数比较概率
-                if (randomValue < (1 - finalProbability))
+                if (randomValue < (1 - finalProbability))  // probability
                 {
                     isseePerson = true;
                     this.isseePerson = true;
@@ -229,7 +229,7 @@ public class AircraftSJ : AircraftEntity
             Console.WriteLine(
                 $"海上任务:{taskContent.missionInformation.MissionName} 机型: {AircraftId} 当前时间:{temptime},当前位置:{currentLocation.CurrentLon},{currentLocation.CurrentLat},{currentLocation.CurrentHei},概率:{probability},最终概率:{1 - finalProbability},是否看到落水人员:{isseePerson},人员是否幸存:{Success}");
 
-            finalProbability = 1 - finalProbability;
+            finalProbability = 1 - finalProbability; //
 
             if (fireIndex != -1)
             {

+ 24 - 24
SimulationServer/Entity/LandSJRescueMission.cs

@@ -18,7 +18,7 @@ public class LandSJRescueMission : Entity
     // <sheet,<指标名,值列表>>
     public Dictionary<string, Dictionary<string, List<string>>> totalReport = new();
 
-    public Dictionary<string, Dictionary<string, List<string>>> aircraftLandSJDatas = new();
+    public Dictionary<string, Dictionary<string, List<string>>> aircraftSJDatas = new();
 
     public bool IsOver = false;
 
@@ -55,13 +55,13 @@ public class LandSJRescueMission : Entity
         {
             SaveSJ();
             //SaveTotalMH();
-            SaveAircraftLandSJDatas();
+            SaveAircraftSJDatas();
         }
 
         if (currentExecuteCount == ExecutionContext)
         {
             SaveSJ();
-            SaveAircraftLandSJDatas();
+            SaveAircraftSJDatas();
             //SaveTotalMH();
             ReportSJ();
             //this.StartAsyncMH();
@@ -79,30 +79,30 @@ public class LandSJRescueMission : Entity
         // Task.Delay(TimeSpan.FromSeconds(readyTime)).ContinueWith(t => this.StartAsyncXH());
     }
 
-    public void SaveAircraftLandSJDatas()
+    public void SaveAircraftSJDatas()
     {
         foreach (AircraftLandSJ aircraftEntity in aircrafts)
         {
             string key = aircraftEntity.AircraftId;
-            if (!aircraftLandSJDatas.ContainsKey(key))
+            if (!aircraftSJDatas.ContainsKey(key))
             {
-                aircraftLandSJDatas[key] = new Dictionary<string, List<string>>();
+                aircraftSJDatas[key] = new Dictionary<string, List<string>>();
             }
-            if (!aircraftLandSJDatas[key].ContainsKey("识别成功率"))
-                aircraftLandSJDatas[key]["识别成功率"] = new List<string>();
-            //aircraftSJDatas[key]["识别成功率"].Add(aircraftEntity.isseePerson ? "1" : "0");
-            if (!aircraftLandSJDatas[key].ContainsKey("任务准备时间"))
-                aircraftLandSJDatas[key]["任务准备时间"] = new List<string>();
-            aircraftLandSJDatas[key]["任务准备时间"].Add(aircraftEntity.TaskReadyTime.ToString());
-            if (!aircraftLandSJDatas[key].ContainsKey("平均搜索时间"))
-                aircraftLandSJDatas[key]["平均搜索时间"] = new List<string>();
-            aircraftLandSJDatas[key]["平均搜索时间"].Add(aircraftEntity.SearchTime.ToString());
-            if (!aircraftLandSJDatas[key].ContainsKey("总飞行时间"))
-                aircraftLandSJDatas[key]["总飞行时间"] = new List<string>();
-            aircraftLandSJDatas[key]["总飞行时间"].Add(aircraftEntity.TotalTime.ToString());
-            if (!aircraftLandSJDatas[key].ContainsKey("人员存活率"))
-                aircraftLandSJDatas[key]["人员存活率"] = new List<string>();
-            //aircraftSJDatas[key]["人员存活率"].Add(aircraftEntity.Success ? "1" : "0");
+            if (!aircraftSJDatas[key].ContainsKey("识别成功率"))
+                aircraftSJDatas[key]["识别成功率"] = new List<string>();
+            aircraftSJDatas[key]["识别成功率"].Add(aircraftEntity.isseePerson ? "1" : "0");
+            if (!aircraftSJDatas[key].ContainsKey("任务准备时间"))
+                aircraftSJDatas[key]["任务准备时间"] = new List<string>();
+            aircraftSJDatas[key]["任务准备时间"].Add(aircraftEntity.TaskReadyTime.ToString());
+            if (!aircraftSJDatas[key].ContainsKey("平均搜索时间"))
+                aircraftSJDatas[key]["平均搜索时间"] = new List<string>();
+            aircraftSJDatas[key]["平均搜索时间"].Add(aircraftEntity.SearchTime.ToString());
+            if (!aircraftSJDatas[key].ContainsKey("总飞行时间"))
+                aircraftSJDatas[key]["总飞行时间"] = new List<string>();
+            aircraftSJDatas[key]["总飞行时间"].Add(aircraftEntity.TotalTime.ToString());
+            if (!aircraftSJDatas[key].ContainsKey("人员存活率"))
+                aircraftSJDatas[key]["人员存活率"] = new List<string>();
+            aircraftSJDatas[key]["人员存活率"].Add(aircraftEntity.Success ? "1" : "0");
         }
     }
 
@@ -114,7 +114,7 @@ public class LandSJRescueMission : Entity
 
             if (staticCapacity == null) continue;
 
-            staticCapacity.FillData(aircraftEntity.Db);
+            staticCapacity.FillData1(aircraftEntity.Db);
 
             string key = aircraftEntity.AircraftId;
 
@@ -123,7 +123,7 @@ public class LandSJRescueMission : Entity
                 singleReport[key] = new Dictionary<string, Dictionary<string, List<string>>>();
             }
 
-            Dictionary<string, Dictionary<string, string>> staticReport = staticCapacity.GetReport();
+            Dictionary<string, Dictionary<string, string>> staticReport = staticCapacity.GetReport1();
             foreach (var kv in staticReport)
             {
                 if (!singleReport[key].ContainsKey(kv.Key)) singleReport[key][kv.Key] = new Dictionary<string, List<string>>();
@@ -181,7 +181,7 @@ public class LandSJRescueMission : Entity
     public void ReportSJ()
     {
         string data = DateTime.Now.ToString("yyyy-MM-dd");
-        string path = $"Reports/SJ/{data}/{MissionId}";
+        string path = $"Reports/LSX/{data}/{MissionId}";
         if (!Directory.Exists(path)) Directory.CreateDirectory(path);
         foreach (var kv in singleReport)
         {

+ 1 - 1
SimulationServer/Entity/SeaSJRescueMission.cs

@@ -181,7 +181,7 @@ public class SeaSJRescueMission : Entity
     public void ReportSJ()
     {
         string data = DateTime.Now.ToString("yyyy-MM-dd");
-        string path = $"Reports/SJ/{data}/{MissionId}";
+        string path = $"Reports/SSJ/{data}/{MissionId}";
         if (!Directory.Exists(path)) Directory.CreateDirectory(path);
         foreach (var kv in singleReport)
         {

+ 2 - 2
SimulationServer/EventHandler/CreateTaskEventHandler.cs

@@ -312,7 +312,7 @@ public class CreateLandSJEventHandler : AEvent<CreateLandSXTask>
         var taskSys = Game.Scene.GetComponent<TaskComponent>();
         LandSJRescueMission mission = ComponentFactory.Create<LandSJRescueMission>();
         taskSys.LandSJRescueMissions.Add(mission);
-        mission.MissionId = $"陆上搜救援任务 {config.LandSXTask.missionInformation.MissionName}";
+        mission.MissionId = $"陆上搜救援任务 {config.LandSXTask.missionInformation.MissionName}";
         mission.ExecutionContext = config.EditorConfig.runCounts;
         //mission.AddComponent<SJTotalTaskPerformanceComponent>();
         for (int i = 0; i < config.LandSXTask.aircraftInfos.Length; i++)
@@ -346,7 +346,7 @@ public class CreateLandSJEventHandler : AEvent<CreateLandSXTask>
                     aircraft.SearchMissionMode = item;
             }
 
-            aircraft.AddComponent<SJStaticCapacityComponent>(); // 陆上搜救是否需要新建SJStaticCapacityComponent?
+            aircraft.AddComponent<SJStaticCapacityComponent>();
             Log.Info($"创建机型 : {flightPlanEditor.aircraftparameter.AircraftID}");
         }
 

+ 15 - 15
SimulationServer/EventHandler/ServerStartEventHandler.cs

@@ -97,24 +97,24 @@ public class ServerStartEventHandler : AEvent<ServerStart>
         }
         //Console.WriteLine("taskConfig.seaSouJiuTasks.Count:" + taskConfig.seaSouJiuTasks.Count);
         //创建搜救
-        foreach (var seaSJTask in taskConfig.seaSouJiuTasks)
-        {
-            //Console.WriteLine("seaSJTask.missionInformation.MissionName:" + seaSJTask.missionInformation.MissionName);
-            //Console.WriteLine("TargetPointId:" + seaSJTask.TargetPointId);
-            //Console.WriteLine("SearchPayload:" + seaSJTask.SearchPayload);
-            //Console.WriteLine("SearchMode:" + seaSJTask.SearchMode);
-            //Console.WriteLine("RadarTransmitterPower:" + seaSJTask.RadarTransmitterPower);
-            //Console.WriteLine("仿真次数:" + editorConfig.runCounts);
-            Game.EventSystem.Publish(new CreateSeaSJTask
-            { EditorConfig = editorConfig, SeaSJTask = seaSJTask });
-        }
-
-        //foreach (var landSXTask in taskConfig.LandSouXunTasks)
+        //foreach (var seaSJTask in taskConfig.seaSouJiuTasks)
         //{
-        //    Game.EventSystem.Publish(new CreateLandSXTask
-        //    { EditorConfig = editorConfig, LandSXTask = landSXTask });
+        //    //Console.WriteLine("seaSJTask.missionInformation.MissionName:" + seaSJTask.missionInformation.MissionName);
+        //    //Console.WriteLine("TargetPointId:" + seaSJTask.TargetPointId);
+        //    //Console.WriteLine("SearchPayload:" + seaSJTask.SearchPayload);
+        //    //Console.WriteLine("SearchMode:" + seaSJTask.SearchMode);
+        //    //Console.WriteLine("RadarTransmitterPower:" + seaSJTask.RadarTransmitterPower);
+        //    //Console.WriteLine("仿真次数:" + editorConfig.runCounts);
+        //    Game.EventSystem.Publish(new CreateSeaSJTask
+        //    { EditorConfig = editorConfig, SeaSJTask = seaSJTask });
         //}
 
+        foreach (var landSXTask in taskConfig.LandSouXunTasks)
+        {
+            Game.EventSystem.Publish(new CreateLandSXTask
+            { EditorConfig = editorConfig, LandSXTask = landSXTask });
+        }
+
         taskSys.ExecutionContext = editorConfig.runCounts;
         taskSys.Start();
         return UniTask.CompletedTask;