using BHJD.DEMdll.Entity; using KYFramework; using MathNet.Numerics.Distributions; using Model; using MongoDB.Bson; using SimulationCommon; using SimulationServer.Utils; namespace SimulationServer; public class AircraftXCJJ : AircraftEntity { public XCJJTask taskContent; public MissionEndPoint MissionEndPoint; public bool IsOver; public bool Success; public TaskParameter taskParameter; public MissionEndPoint hospitalPoint; public List jiuzhuTimes = new List(); public Dictionary reportInfo = new Dictionary(); public TaskLoad load; public string device; public string medicine; public string hospitalAirport; public override void End() { TotalFuelConsumption = TurningPoints[0].RemainingFuel - TurningPoints[^1].RemainingFuel; } public override void Reset() { base.Reset(); IsOver = false; Success = false; TotalTime = 0; reportInfo = new Dictionary(); device = string.Empty; medicine = string.Empty; } public override void Start() { FlightPlanEditor.missionpoint.MissionPointLatitude = FlightPlanEditor.medicalTargetPoint[0].TargetPointLatitude; FlightPlanEditor.missionpoint.MissionPointLongitude = FlightPlanEditor.medicalTargetPoint[0].TargetPointLongitude; FlightPlanEditor.missionpoint.MissionPointHeight = FlightPlanEditor.medicalTargetPoint[0].TargetPointHeight; //Console.WriteLine("Latitude:" + FlightPlanEditor.missionpoint.MissionPointLatitude + "_" + "Longitude:" + FlightPlanEditor.missionpoint.MissionPointLongitude + "_" + "Height:" + FlightPlanEditor.missionpoint.MissionPointHeight); int patientCount = FlightPlanEditor.medicalTargetPoint[0].TargetType.Count; // 伤患人数 List diseaseTypes = new List(); for (int i = 0; i < FlightPlanEditor.medicalTargetPoint[0].TargetType.diseaseTypes.Length; i++) { diseaseTypes.Add(FlightPlanEditor.medicalTargetPoint[0].TargetType.diseaseTypes[i]); } int medicCount = taskParameter.doctorPersonnel + taskParameter.nursePersonnel + taskParameter.nurseSeverePersonnel;//taskParameter.MedicalStaffCount; // 医护人员数量 //Console.WriteLine("medicCount:" + medicCount); // 交接时间为5分钟 double handoverTime = 5; // 计算总急救时间 需要飞机停留时间 double totalEmergencyTime = CalculateTotalEmergencyTime(diseaseTypes); // 计算平均急救时间(每个医护人员分担的时间) double averageEmergencyTimePerMedic = totalEmergencyTime / medicCount; // 计算总时间(平均急救时间 + 交接时间) double totalTime = averageEmergencyTimePerMedic + handoverTime; Console.WriteLine($"总急救时间(平均每个医护人员): {averageEmergencyTimePerMedic} 分钟"); Console.WriteLine($"总时间(包括交接时间): {totalTime} 分钟"); Random rand = new Random(); List patients = new List(); for (int i = 0; i < patientCount; i++) { patients.Add(new Patient() { Id = i + 1, DiseaseType = diseaseTypes[i], GoldenHour = 0 }); } patients = MedicalRescue.ProcessPatients(patients, rand); // 对患者进行排序 var sortedPatients = patients.OrderBy(p => DiseasePriorityService.GetPriority(p.DiseaseType)) .ThenBy(p => p.GoldenHour) .ToList(); // 输出排序后的患者列表 // 从是事故点到医院的飞行时间 + 5分钟的交接时间 < 黄金时间 ? 成功:失败 foreach (var patient in sortedPatients) { Console.WriteLine($"sortedPatients ID: {patient.Id}, Disease: {patient.DiseaseType}, Golden Hour: {patient.GoldenHour:F2}"); } // 注意:实际项目中,每次转运一名伤员的操作可能涉及更多的逻辑,比如更新数据库中的转运状态等。 FXJHGenerate.FromStartToMission(FlightPlanEditor, ref TurningPoints);//生成从起点到任务段起点的航路点 FXJHGenerate.JIJIU(totalTime, FlightPlanEditor, ref TurningPoints); FXJHGenerate.JIJIU1(5 * 60, hospitalPoint, ref TurningPoints); for (int i = 0; i < FlightPlanEditor.medicalTargetPoint[0].TargetType.Count - 1; i++) { FXJHGenerate.JIJIU(5 * 60, FlightPlanEditor, ref TurningPoints); FXJHGenerate.JIJIU1(5 * 60, hospitalPoint, ref TurningPoints); } FXJHGenerate.FromMissionToEnd(FlightPlanEditor, hospitalPoint, ref TurningPoints); FXJHGenerate.FXJHTPDiedai(FlightPlanEditor, ref TurningPoints, Velocitys, FuelConsumptions); double time = 0; for (int i = 2; i < 5; i++) { time += TurningPoints[i].SegmentFlightTime; } jiuzhuTimes.Add(time); int p = 5; int c = 0; for (int i = p; i < FlightPlanEditor.medicalTargetPoint[0].TargetType.Count * 4 + 1; i++) { time += TurningPoints[i].SegmentFlightTime; c++; if (c == 4) { jiuzhuTimes.Add(time); c = 0; } } for (int i = 0; i < TurningPoints.Count; i++) // 总飞行时间 { TotalTime += TurningPoints[i].SegmentFlightTime; // 总时间 //仿真轮次1 数值1 } Console.WriteLine("TotalTime:" + TotalTime); reportInfo.Add("准备时间", TaskReadyTime.ToString()); double reachTime = 0; for (int i = 0; i < 2; i++) { reachTime += TurningPoints[i].SegmentFlightTime; } reportInfo.Add("到达时间", reachTime.ToString()); // 基地 -> 目标点 reportInfo.Add("任务周期时间", TotalTime.ToString()); reportInfo.Add("执行任务飞机型号", Name); reportInfo.Add("执行任务飞机数量", "1"); reportInfo.Add("单机飞行员人数", taskParameter.pilotPersonnel.ToString()); reportInfo.Add("单机医师人数", taskParameter.doctorPersonnel.ToString()); reportInfo.Add("单机护士人数", taskParameter.nursePersonnel.ToString()); reportInfo.Add("单机重症监护护理人员人数", taskParameter.nurseSeverePersonnel.ToString()); reportInfo.Add("单机地面保障人数", taskParameter.groundSupportPersonnel.ToString()); reportInfo.Add("单机总任务时长", TotalTime.ToString()); reportInfo.Add("单机总油耗", FXJHGenerate.CalculateTotalFuelConsumption(FlightPlanEditor, TurningPoints).ToString()); reportInfo.Add("单机机场使用情况", Airport + "\r\n" + hospitalAirport); double zhc = 0; for (int i = 0; i < TurningPoints.Count - 1; i++) { zhc += Utils.Util.GetDistance(TurningPoints[i].TurningPointLongitude, TurningPoints[i + 1].TurningPointLongitude, TurningPoints[i].TurningPointLatitude, TurningPoints[i + 1].TurningPointLatitude); } reportInfo.Add("单机导航使用情况", zhc.ToString()); //飞行总距离 if(load.FirstAid != null) { for (int i = 0; i < load.FirstAid.Length; i++) { device += load.FirstAid[i]; device += "\r\n"; } } if (load.HandlingAndFixing != null) { for (int i = 0; i < load.HandlingAndFixing.Length; i++) { device += load.HandlingAndFixing[i]; device += "\r\n"; } } if (load.DiagnosisAndMonitoring != null) { for (int i = 0; i < load.DiagnosisAndMonitoring.Length; i++) { device += load.DiagnosisAndMonitoring[i]; device += "\r\n"; } } if (load.Trauma != null) { for (int i = 0; i < load.Trauma.Length; i++) { device += load.Trauma[i]; device += "\r\n"; } } if (load.Infusion != null) { for (int i = 0; i < load.Infusion.Length; i++) { device += load.Infusion[i]; device += "\r\n"; } } if (load.Drug != null) { for (int i = 0; i < load.Drug.Length; i++) { medicine += load.Drug[i]; if (i != load.Drug.Length - 1) medicine += "\r\n"; } } char[] cs = { '\r', '\n' }; device = device.TrimEnd(cs); //Console.WriteLine("医疗任务设备:" + device); //Console.WriteLine("医疗药品:" + medicine); if (device != null) reportInfo.Add("医疗任务设备", device); else reportInfo.Add("医疗任务设备", ""); if (medicine != null) reportInfo.Add("医疗药品", medicine); else reportInfo.Add("医疗药品", ""); reportInfo.Add("任务缓急情况", "紧急"); IsOver = true; End(); } static double CalculateTotalEmergencyTime(List diseaseTypes) { double totalTime = 0; // 这里假设有一个方法GetEmergencyTimeFromDatabase,它根据疾病类型从数据库获取急救时间,此处应为从数据库中读取 foreach (var diseaseType in diseaseTypes) { double emergencyTime = GetEmergencyTimeFromDatabase(diseaseType); totalTime += emergencyTime; } return totalTime; } // 模拟从数据库获取急救时间的方法 static double GetEmergencyTimeFromDatabase(string diseaseType) { // 这里应该是实际的数据库查询逻辑 // 但为了示例,我们直接返回一个模拟值 switch (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; } } // 假设从前端接收到的数据结构 public class Patient { public int Id { get; set; } public string DiseaseType { get; set; } public double GoldenHour { get; set; } // 患者的黄金救援时间应由黄金救援时间程序获得 } public class DiseaseInfo { public string DiseaseType { get; set; } public double MinGoldenHour { get; set; } public double MaxGoldenHour { get; set; } } public class MedicalRescue { private static Dictionary diseaseDatabase = new Dictionary { { "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 ProcessPatients(List 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) { if (diseaseDatabase.ContainsKey(diseaseType)) { return diseaseDatabase[diseaseType]; } throw new ArgumentException("Unknown disease type."); } public static double GenerateRandomGoldenHour(Random rand, double min, double max) { double mu = (max + min) / 2; double sigma = (max - min) / 6; var normal = new Normal(mu, sigma); return normal.Sample(); } } // 假设数据库中的疾病优先级信息 public class DiseasePriority { public string DiseaseType { get; set; } public int Priority { get; set; } // 优先级,数字越小优先级越高 } // 静态类,包含与疾病优先级相关的静态方法 public static class DiseasePriorityService { // 数据库查询(实际项目中应该是从数据库读取) public static List GetDiseasePriorities() { return new List { 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; // 如果没有找到,返回一个很大的数作为默认优先级 } } public string TargetQiXiangInfoSave(string s, int hour) { string result = hour.ToString() + "-" + s; for (int i = 0; i < FlightPlanEditor.medicalTargetPoint[0].TargetQiXiangInfos.Length; i++) { } switch (s) { case "温度": break; case "湿度": break; case "能见度": break; case "风速": break; case "风向": break; case "天气": break; } return result; } } [ObjectSystem] public class AircraftXCJJAwakeSystem : AwakeSystem { public override void Awake(AircraftXCJJ self, FlightPlanEditor flightPlanEditor) { self.FlightPlanEditor = flightPlanEditor; self.Awake(); } }