using System; using System.Collections.Generic; using System.Text; using System.Text.Json; namespace AI.Platform.Page.Pages.Media { public class Utils { private static Dictionary _StateDic = new Dictionary() { { "idle","空闲" },{ "lock","锁枪" },{ "offline","脱机" },{ "lift","提枪" },{ "authorised","授权" },{ "start","开始" },{ "fueling","加油中" } }; /// /// 根据数据库中的油枪状态json转中文拼接 /// /// /// public static string MachineStateJsonToString(string jsonStr) { List? list = JsonSerializer.Deserialize>(jsonStr); if (list == null || list.Count == 0) return ""; var result = ""; foreach(string item in list) { string? state = _StateDic.GetValueOrDefault(item); if (state == null || state.Length == 0) continue; result += state + ","; } return result.Remove(result.Length - 1); } public static string JoinDateTime(DateTime start,DateTime end) { return $"{start}-{end}"; } } }