123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326 |
- 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<double> jiuzhuTimes = new List<double>();
- public Dictionary<string,string> reportInfo = new Dictionary<string,string>();
- 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<string, string>();
- }
- 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<string> diseaseTypes = new List<string>();
- for (int i = 0; i < FlightPlanEditor.medicalTargetPoint[0].TargetType.diseaseTypes.Length; i++)
- {
- diseaseTypes.Add(FlightPlanEditor.medicalTargetPoint[0].TargetType.diseaseTypes[i]);
- }
- int medicCount = taskParameter.MedicalStaffCount;
-
- 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<Patient> patients = new List<Patient>();
- 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();
-
- 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;
- }
- Console.WriteLine("TotalTime:" + TotalTime);
- reportInfo.Add("准备时间", TaskReadyTime.ToString());
- double reachTime = 0;
- for (int i = 2; i < 4; i++)
- {
- reachTime += TurningPoints[i].SegmentFlightTime;
- }
- reportInfo.Add("到达时间", TaskReadyTime.ToString());
- reportInfo.Add("任务周期时间", TotalTime.ToString());
- reportInfo.Add("执行任务飞机型号", Name);
- reportInfo.Add("执行任务飞机数量", "1");
- reportInfo.Add("单机飞行员人数", "1");
- reportInfo.Add("单机医师人数", "1");
- reportInfo.Add("单机护士人数", "1");
- reportInfo.Add("单机重症监护护理人员人数", "0");
- reportInfo.Add("单机地面保障人数", "1");
- reportInfo.Add("单机总任务时长", TotalTime.ToString());
- reportInfo.Add("单机机场使用情况", Airport);
- reportInfo.Add("任务缓急情况", "紧急");
- IsOver = true;
- End();
- }
- static double CalculateTotalEmergencyTime(List<string> diseaseTypes)
- {
- double totalTime = 0;
-
- foreach (var diseaseType in diseaseTypes)
- {
- double emergencyTime = GetEmergencyTimeFromDatabase(diseaseType);
- totalTime += emergencyTime;
- }
- return totalTime;
- }
-
- static double GetEmergencyTimeFromDatabase(string diseaseType)
- {
-
-
- switch (diseaseType)
- {
- case "aa":
- return 2;
- case "bb":
- return 5;
- case "cc":
- return 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<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);
- 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<DiseasePriority> GetDiseasePriorities()
- {
- 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;
- }
- }
- 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<AircraftXCJJ, FlightPlanEditor>
- {
- public override void Awake(AircraftXCJJ self, FlightPlanEditor flightPlanEditor)
- {
- self.FlightPlanEditor = flightPlanEditor;
- self.Awake();
- }
- }
|