Browse Source

医疗场景完成输出报告数据关联

liyang 3 months ago
parent
commit
192476419b

+ 3 - 0
SimulationServer/Entity/AircraftEntity.cs

@@ -37,6 +37,9 @@ public class AircraftEntity : Entity
 
 
     public void Awake()
     public void Awake()
     {
     {
+        //Console.WriteLine("AircraftType:" + FlightPlanEditor.aircraftparameter.AircraftType);
+        //Console.WriteLine("AircraftSubType:" + FlightPlanEditor.aircraftparameter.AircraftSubType);
+        //Console.WriteLine("AircraftID:" + FlightPlanEditor.aircraftparameter.AircraftID);
         Db = Util.GetAircraftDefine(FlightPlanEditor.aircraftparameter.AircraftType, FlightPlanEditor.aircraftparameter.AircraftSubType, FlightPlanEditor.aircraftparameter.AircraftID);
         Db = Util.GetAircraftDefine(FlightPlanEditor.aircraftparameter.AircraftType, FlightPlanEditor.aircraftparameter.AircraftSubType, FlightPlanEditor.aircraftparameter.AircraftID);
 
 
         if (Db.f_zdqfzl != null)
         if (Db.f_zdqfzl != null)

+ 0 - 1
SimulationServer/Entity/AircraftXCJJ.cs

@@ -342,7 +342,6 @@ public class AircraftXCJJ : AircraftEntity
 
 
     public double GetPriority(string diseaseType)
     public double GetPriority(string diseaseType)
     {
     {
-
         if (diseaseDatabase.ContainsKey(diseaseType))
         if (diseaseDatabase.ContainsKey(diseaseType))
         {
         {
             return diseaseDatabase[diseaseType].Priority;
             return diseaseDatabase[diseaseType].Priority;

+ 53 - 84
SimulationServer/Entity/AircraftYLZY.cs

@@ -25,6 +25,8 @@ public class AircraftYLZY : AircraftEntity
 
 
     public string hospitalAirport;
     public string hospitalAirport;
 
 
+    private Dictionary<string, DiseaseInfo> diseaseDatabase = new Dictionary<string, DiseaseInfo>();
+
     public override void End()
     public override void End()
     {
     {
         TotalFuelConsumption = TurningPoints[0].RemainingFuel - TurningPoints[^1].RemainingFuel;
         TotalFuelConsumption = TurningPoints[0].RemainingFuel - TurningPoints[^1].RemainingFuel;
@@ -43,6 +45,22 @@ public class AircraftYLZY : AircraftEntity
 
 
     public override void Start()
     public override void Start()
     {
     {
+        for (int i = 1; i < 19; i++)
+        {
+            string s = Utils.Util.GetYL(i.ToString());
+            string[] r = s.Split('-');
+            diseaseDatabase.Add(r[0], new DiseaseInfo { MinGoldenHour = Convert.ToDouble(r[1]), MaxGoldenHour = Convert.ToDouble(r[2]), Priority = Convert.ToDouble(r[3]), RescueTime = Convert.ToDouble(r[4]) });
+        }
+
+        //foreach (var item in diseaseDatabase)
+        //{
+        //    Console.WriteLine("疾病类型:" + item.Key);
+        //    Console.WriteLine("最小黄金救援时间:" + item.Value.MinGoldenHour);
+        //    Console.WriteLine("最大黄金救援时间:" + item.Value.MaxGoldenHour);
+        //    Console.WriteLine("优先级:" + item.Value.Priority);
+        //    Console.WriteLine("抢救时间:" + item.Value.RescueTime);
+        //}
+
         FlightPlanEditor.missionpoint.MissionPointLatitude = FlightPlanEditor.medicalTargetPoint[0].TargetPointLatitude;
         FlightPlanEditor.missionpoint.MissionPointLatitude = FlightPlanEditor.medicalTargetPoint[0].TargetPointLatitude;
         FlightPlanEditor.missionpoint.MissionPointLongitude = FlightPlanEditor.medicalTargetPoint[0].TargetPointLongitude;
         FlightPlanEditor.missionpoint.MissionPointLongitude = FlightPlanEditor.medicalTargetPoint[0].TargetPointLongitude;
         FlightPlanEditor.missionpoint.MissionPointHeight = FlightPlanEditor.medicalTargetPoint[0].TargetPointHeight;
         FlightPlanEditor.missionpoint.MissionPointHeight = FlightPlanEditor.medicalTargetPoint[0].TargetPointHeight;
@@ -68,8 +86,8 @@ public class AircraftYLZY : AircraftEntity
         // 计算总时间(平均急救时间 + 交接时间)  
         // 计算总时间(平均急救时间 + 交接时间)  
         double totalTime = averageEmergencyTimePerMedic + handoverTime;
         double totalTime = averageEmergencyTimePerMedic + handoverTime;
 
 
-        Console.WriteLine($"总急救时间(平均每个医护人员): {averageEmergencyTimePerMedic} 分钟");
-        Console.WriteLine($"总时间(包括交接时间): {totalTime} 分钟");
+        //Console.WriteLine($"总急救时间(平均每个医护人员): {averageEmergencyTimePerMedic} 分钟");
+        //Console.WriteLine($"总时间(包括交接时间): {totalTime} 分钟");
 
 
         Random rand = new Random();
         Random rand = new Random();
         List<Patient> patients = new List<Patient>();
         List<Patient> patients = new List<Patient>();
@@ -83,17 +101,17 @@ public class AircraftYLZY : AircraftEntity
             });
             });
         }
         }
 
 
-        patients = MedicalRescue.ProcessPatients(patients, rand);
+        patients = ProcessPatients(patients, rand);
 
 
         // 对患者进行排序  
         // 对患者进行排序  
-        var sortedPatients = patients.OrderBy(p => DiseasePriorityService.GetPriority(p.DiseaseType))
+        var sortedPatients = patients.OrderBy(p => GetPriority(p.DiseaseType))
                                     .ThenBy(p => p.GoldenHour)
                                     .ThenBy(p => p.GoldenHour)
                                     .ToList();
                                     .ToList();
 
 
         // 输出排序后的患者列表    // 从是事故点到医院的飞行时间 + 5分钟的交接时间 < 黄金时间 ? 成功:失败
         // 输出排序后的患者列表    // 从是事故点到医院的飞行时间 + 5分钟的交接时间 < 黄金时间 ? 成功:失败
         foreach (var patient in sortedPatients)
         foreach (var patient in sortedPatients)
         {
         {
-            Console.WriteLine($"sortedPatients ID: {patient.Id}, Disease: {patient.DiseaseType}, Golden Hour: {patient.GoldenHour:F2}");
+            //Console.WriteLine($"sortedPatients ID: {patient.Id}, Disease: {patient.DiseaseType}, Golden Hour: {patient.GoldenHour:F2}");
         }
         }
 
 
         // 注意:实际项目中,每次转运一名伤员的操作可能涉及更多的逻辑,比如更新数据库中的转运状态等。  
         // 注意:实际项目中,每次转运一名伤员的操作可能涉及更多的逻辑,比如更新数据库中的转运状态等。  
@@ -209,7 +227,7 @@ public class AircraftYLZY : AircraftEntity
         End();
         End();
     }
     }
 
 
-    static double CalculateTotalEmergencyTime(List<string> diseaseTypes)
+    public double CalculateTotalEmergencyTime(List<string> diseaseTypes)
     {
     {
         double totalTime = 0;
         double totalTime = 0;
 
 
@@ -224,25 +242,13 @@ public class AircraftYLZY : AircraftEntity
     }
     }
 
 
     // 模拟从数据库获取急救时间的方法  
     // 模拟从数据库获取急救时间的方法  
-    static double GetEmergencyTimeFromDatabase(string diseaseType)
+    public double GetEmergencyTimeFromDatabase(string diseaseType)
     {
     {
-        // 这里应该是实际的数据库查询逻辑  
-        // 但为了示例,我们直接返回一个模拟值  
-        switch (diseaseType)
+        if (diseaseDatabase.ContainsKey(diseaseType))
         {
         {
-            case "aa": //HeartAttack
-                return 2; // 心脏病急救时间为2分钟  
-            case "bb": //Stroke
-                return 5; // 中风急救时间为5分钟  
-            case "cc": //Trauma
-                return 10; // 创伤急救时间为10分钟  
-            case "dd":
-                return 15;
-            case "ee":
-                return 20;
-            default:
-                return 0;
+            return diseaseDatabase[diseaseType].RescueTime;
         }
         }
+        throw new ArgumentException("Unknown disease type.");
     }
     }
 
 
     // 假设从前端接收到的数据结构  
     // 假设从前端接收到的数据结构  
@@ -255,86 +261,49 @@ public class AircraftYLZY : AircraftEntity
 
 
     public class DiseaseInfo
     public class DiseaseInfo
     {
     {
-        public string DiseaseType { get; set; }
         public double MinGoldenHour { get; set; }
         public double MinGoldenHour { get; set; }
         public double MaxGoldenHour { get; set; }
         public double MaxGoldenHour { get; set; }
+
+        public double Priority { get; set; }
+        public double RescueTime { get; set; }
     }
     }
 
 
-    public class MedicalRescue
+    public List<Patient> ProcessPatients(List<Patient> patients, Random rand)
     {
     {
-        private static Dictionary<string, DiseaseInfo> diseaseDatabase = new Dictionary<string, DiseaseInfo>
-        {
-            { "aa", new DiseaseInfo { DiseaseType = "aa", MinGoldenHour = 1, MaxGoldenHour = 3 } },
-            { "bb", new DiseaseInfo { DiseaseType = "bb", MinGoldenHour = 2, MaxGoldenHour = 4 } },
-            { "cc", new DiseaseInfo { DiseaseType = "cc", MinGoldenHour = 3, MaxGoldenHour = 5 } },
-            { "dd", new DiseaseInfo { DiseaseType = "dd", MinGoldenHour = 4, MaxGoldenHour = 6 } },
-            { "ee", new DiseaseInfo { DiseaseType = "ee", MinGoldenHour = 5, MaxGoldenHour = 7 } },  
-        // 添加更多疾病类型
-        };
-
-        public static List<Patient> ProcessPatients(List<Patient> patients, Random rand)
-        {
-            foreach (var patient in patients)
-            {
-                var diseaseInfo = GetDiseaseInfo(patient.DiseaseType); // MinGoldenHour MaxGoldenHour 数据库读取
-                double goldenHour = GenerateRandomGoldenHour(rand, diseaseInfo.MinGoldenHour, diseaseInfo.MaxGoldenHour);
-                Console.WriteLine($"Patient ID: {patient.Id}, Disease: {patient.DiseaseType}, Golden Hour: {goldenHour:F2}");
-                patient.GoldenHour = goldenHour;
-            }
-            return patients;
-        }
-
-        public static DiseaseInfo GetDiseaseInfo(string diseaseType)
+        foreach (var patient in patients)
         {
         {
-            if (diseaseDatabase.ContainsKey(diseaseType))
-            {
-                return diseaseDatabase[diseaseType];
-            }
-            throw new ArgumentException("Unknown disease type.");
+            var diseaseInfo = GetDiseaseInfo(patient.DiseaseType); // MinGoldenHour MaxGoldenHour 数据库读取
+            double goldenHour = GenerateRandomGoldenHour(rand, diseaseInfo.MinGoldenHour, diseaseInfo.MaxGoldenHour);
+            //Console.WriteLine($"Patient ID: {patient.Id}, Disease: {patient.DiseaseType}, Golden Hour: {goldenHour:F2}");
+            patient.GoldenHour = goldenHour;
         }
         }
+        return patients;
+    }
 
 
-        public static double GenerateRandomGoldenHour(Random rand, double min, double max)
+    public DiseaseInfo GetDiseaseInfo(string diseaseType)
+    {
+        if (diseaseDatabase.ContainsKey(diseaseType))
         {
         {
-            double mu = (max + min) / 2;
-            double sigma = (max - min) / 6;
-            var normal = new Normal(mu, sigma);
-            return normal.Sample();
+            return diseaseDatabase[diseaseType];
         }
         }
+        throw new ArgumentException("Unknown disease type.");
     }
     }
 
 
-    // 假设数据库中的疾病优先级信息  
-    public class DiseasePriority
+    public static double GenerateRandomGoldenHour(Random rand, double min, double max)
     {
     {
-        public string DiseaseType { get; set; }
-        public int Priority { get; set; } // 优先级,数字越小优先级越高  
+        double mu = (max + min) / 2;
+        double sigma = (max - min) / 6;
+        var normal = new Normal(mu, sigma);
+        return normal.Sample();
     }
     }
 
 
-    // 静态类,包含与疾病优先级相关的静态方法  
-    public static class DiseasePriorityService
+    public double GetPriority(string diseaseType)
     {
     {
-        // 数据库查询(实际项目中应该是从数据库读取)  
-        public static List<DiseasePriority> GetDiseasePriorities()
+        if (diseaseDatabase.ContainsKey(diseaseType))
         {
         {
-            return new List<DiseasePriority>
-            {
-                new DiseasePriority { DiseaseType = "aa", Priority = 5 },
-                new DiseasePriority { DiseaseType = "bb", Priority = 4 },
-                new DiseasePriority { DiseaseType = "cc", Priority = 3 },
-                new DiseasePriority { DiseaseType = "dd", Priority = 2 },
-                new DiseasePriority { DiseaseType = "ee", Priority = 5 },
-            };
-        }
-
-        // 根据疾病类型获取优先级  
-        public static int GetPriority(string diseaseType)
-        {
-            var priorities = GetDiseasePriorities().ToDictionary(dp => dp.DiseaseType, dp => dp.Priority);
-            if (priorities.TryGetValue(diseaseType, out int priority))
-            {
-                return priority;
-            }
-            return int.MaxValue; // 如果没有找到,返回一个很大的数作为默认优先级  
+            return diseaseDatabase[diseaseType].Priority;
         }
         }
+        throw new ArgumentException("Unknown disease type.");
     }
     }
 
 
     public string TargetQiXiangInfoSave(string s, int hour)
     public string TargetQiXiangInfoSave(string s, int hour)

+ 16 - 16
SimulationServer/EventHandler/ServerStartEventHandler.cs

@@ -198,23 +198,23 @@ public class ServerStartEventHandler : AEvent<ServerStart>
             //break;
             //break;
         }
         }
 
 
-        ////医疗转运任务
-        //foreach (var YLZYTask in taskConfig.YLZYTasks)
-        //{
-        //    taskSys.missionCount++;
-        //    Game.EventSystem.Publish(new CreateYLZYTask
-        //    { EditorConfig = editorConfig, YLZYTask = YLZYTask });
-        //    //break;
-        //}
+        //医疗转运任务
+        foreach (var YLZYTask in taskConfig.YLZYTasks)
+        {
+            taskSys.missionCount++;
+            Game.EventSystem.Publish(new CreateYLZYTask
+            { EditorConfig = editorConfig, YLZYTask = YLZYTask });
+            //break;
+        }
 
 
-        ////医疗物品运送
-        //foreach (var YLWPYSTask in taskConfig.YLWPYSTasks)
-        //{
-        //    taskSys.missionCount++;
-        //    Game.EventSystem.Publish(new CreateYLWPYSTask
-        //    { EditorConfig = editorConfig, YLWPYSTask = YLWPYSTask });
-        //    //break;
-        //}
+        //医疗物品运送
+        foreach (var YLWPYSTask in taskConfig.YLWPYSTasks)
+        {
+            taskSys.missionCount++;
+            Game.EventSystem.Publish(new CreateYLWPYSTask
+            { EditorConfig = editorConfig, YLWPYSTask = YLWPYSTask });
+            //break;
+        }
 
 
         ////绞车吊载转运任务
         ////绞车吊载转运任务
         //foreach (var JCDZZYTask in taskConfig.JCDZZYTasks)
         //foreach (var JCDZZYTask in taskConfig.JCDZZYTasks)

BIN
SimulationServer/bin/Debug/net7.0/SimulationServer.dll


BIN
SimulationServer/bin/Debug/net7.0/SimulationServer.exe


BIN
SimulationServer/bin/Debug/net7.0/SimulationServer.pdb