123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- using BHJD.DEMdll.Public;
- using Newtonsoft.Json;
- namespace SimulationCommon;
- public class Util
- {
- public static string serverIp = "10.130.100.5";
- public static string baseURl = $"http://{serverIp}:7785//";
-
- public static Fuel GetFuel(string fName, string fType, string fState, string fTemperature, string fHeight, string fWeight)
- {
- Console.WriteLine($"fName:{fName},fType:{fType},fState:{fState},fTemperature:{fTemperature},fHeight:{fHeight},fWeight:{fWeight}");
- IHttpHelper.HttpCmd cmd = new IHttpHelper.HttpCmd
- {
- m_RequestType = IHttpHelper.HttpRequestType.POST,
- m_Addr = $"{baseURl}rescue-platform-service/api/v1/tbTables/queryOilConsumeInfo",
- };
- HttpHelper m_HttpHelper = new HttpHelper();
- string json = JsonConvert.SerializeObject(new
- {
- fname = fName, ftype = fType, fstate = fState, ftemperature = fTemperature, fheight = fHeight,
- fweight = fWeight
- });
- Fuel fuel = null;
- try
- {
- string response = m_HttpHelper.HttpPost(cmd, json);
- var fuelDb = JsonConvert.DeserializeObject<FuelDB>(response);
- if (fuelDb.data.Count > 0)
- fuel = fuelDb.data[0];
- else
- {
- //Console.WriteLine($"没有找到【{json}】对应的油耗信息");
- }
- }
- catch (Exception e)
- {
- //Console.WriteLine($"没有找到【{json}】对应的油耗信息");
- }
- return fuel;
- }
-
- /// <summary>
- /// 获取当前位置的温度
- /// </summary>
- /// <param name="varName"></param>
- /// <param name="lon"></param>
- /// <param name="lat"></param>
- /// <param name="data"></param>
- /// <returns></returns>
- public static double GetTemperature(double lon, double lat)
- {
- IHttpHelper.HttpCmd cmd = new IHttpHelper.HttpCmd
- {
- m_RequestType = IHttpHelper.HttpRequestType.GET,
- m_Addr = $"{baseURl}rescue-platform-service/api/v1/attribute/getInfos",
- m_Args = new List<string> { "varName","centerLon","centerLat","weather_date" }
- };
-
- HttpHelper m_HttpHelper = new HttpHelper();
- string response = m_HttpHelper.Request(cmd, new List<string> { "t2m",lon.ToString(),lat.ToString(),"2024-01-01 12:00:00" });
- var temp = JsonConvert.DeserializeObject<Temperature>(response);
- Console.WriteLine(response);
- return temp.value - 273;
- }
- }
|